From 77e43462eae95c901fa117a6f55713de96690fa0 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Tue, 27 Jan 2026 20:35:05 +0800 Subject: [PATCH] dev ing --- internal/logic/strategy/rule/roe.go | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 internal/logic/strategy/rule/roe.go diff --git a/internal/logic/strategy/rule/roe.go b/internal/logic/strategy/rule/roe.go new file mode 100644 index 0000000..55fa83a --- /dev/null +++ b/internal/logic/strategy/rule/roe.go @@ -0,0 +1,45 @@ +package rule + +import ( + "fmt" + + "git.apinb.com/quant/gostock/internal/impl" + "git.apinb.com/quant/gostock/internal/logic/types" + "git.apinb.com/quant/gostock/internal/models" +) + +var ( + MinRoe = 0 +) + +type Roe struct { + Key string + Name string +} + +func NewRoe() *Roe { + return &Roe{ + Key: "Roe", + Name: "年化净资产收益率", + } +} + +func (r *Roe) Run(code string) *types.RuleResult { + + var data []models.StockDaily + impl.DBService.Where("ts_code = ?", code).Order("trade_date desc").Limit(LastDay).Find(&data) + + check := true + for _, row := range data { + if row.Close < MinPrice { + check = false + break + } + } + + if !check { + return &types.RuleResult{Key: r.Key, Name: r.Name, Score: -1, Desc: fmt.Sprintf("最近%d天, 有价格低于%.2f", LastDay, MinPrice)} + } + + return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: fmt.Sprintf("最近%d天, 价格均高于%.2f", LastDay, MinPrice)} +}