This commit is contained in:
yanweidong
2026-01-31 18:22:58 +08:00
parent b4310c22cd
commit 32cbe88964
12 changed files with 104 additions and 155 deletions

View File

@@ -2,10 +2,10 @@ package rule
import (
"fmt"
"log"
"git.apinb.com/bsm-sdk/core/utils"
"git.apinb.com/quant/gostock/internal/impl"
"git.apinb.com/quant/gostock/internal/logic/types"
"git.apinb.com/quant/gostock/internal/models"
)
@@ -13,31 +13,26 @@ var (
MinRoe float64 = 0
)
type Roe struct {
Key string
Name string
}
func NewRoe() *Roe {
return &Roe{
Key: "Roe",
Name: "年化净资产收益率",
}
}
func (r *Roe) Run(code string) *types.RuleResult {
func (r *RuleFactory) RunRoe(code string) {
log.Println("RunRoe:", r.Model.Code)
var data models.StockFinaIndicator
err := impl.DBService.Where("ts_code = ?", code).Order("period desc").Limit(1).First(&data).Error
if err != nil {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: "最近无财报无ROE值"}
r.Model.GtAmount = -1
r.Model.AddDesc("最近无财报无ROE值")
return
}
data.Roe = utils.FloatRound(data.Roe, 2)
if data.Roe < MinRoe {
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe)}
r.Model.GtAmount = -1
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 低于%.2f", data.Roe, MinRoe))
return
}
return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe)}
r.Model.GtAmount = 1
r.Model.AddDesc(fmt.Sprintf("ROE=%.2f 高于%.2f", data.Roe, MinRoe))
return
}