From e59e89f15c5f9a7229d26cdacf85f6412769d145 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Wed, 28 Jan 2026 02:18:48 +0800 Subject: [PATCH] fix bug --- cmd/cli/main.go | 28 ++++++++++++++++++++----- internal/logic/strategy/data.go | 5 +++++ internal/logic/strategy/rule/up_date.go | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index cdbb90c..1e1e452 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -20,8 +20,30 @@ func main() { config.New(ServiceKey) impl.NewImpl() - basic := strategy.GetBasic("000012.SZ") + var okStocks []string + for _, code := range strategy.GetStocks() { + basic := strategy.GetBasic(code) + result := rule.NewUpDate().Run(basic.ListDate) + if result.Score >0 { + okStocks = append(okStocks, code) + } else + result := []*types.RuleResult{ + , + rule.NewST().Run(basic.Name), + rule.NewIdustry().Run(basic.Industry), + rule.NewPrice().Run(basic.TsCode), + rule.NewAmount().Run(basic.TsCode), + } + } + + printer.Json(result) + + log.Println("Done!") +} + +func RuleFilter(code string){ + basic := strategy.GetBasic(code) result := []*types.RuleResult{ rule.NewUpDate().Run(basic.ListDate), rule.NewST().Run(basic.Name), @@ -29,8 +51,4 @@ func main() { rule.NewPrice().Run(basic.TsCode), rule.NewAmount().Run(basic.TsCode), } - - printer.Json(result) - - log.Println("Done!") } diff --git a/internal/logic/strategy/data.go b/internal/logic/strategy/data.go index 3c41d4d..a372a7e 100644 --- a/internal/logic/strategy/data.go +++ b/internal/logic/strategy/data.go @@ -21,6 +21,11 @@ func GetFullData(code string) *StockData { return &data } +func GetStocks() (stocks []string) { + impl.DBService.Model(&models.StockBasic{}).Group("ts_code").Pluck("ts_code", &stocks) + return +} + func GetIndustry() (industry []string) { impl.DBService.Model(&models.StockBasic{}).Group("industry").Pluck("industry", &industry) return diff --git a/internal/logic/strategy/rule/up_date.go b/internal/logic/strategy/rule/up_date.go index a45fd1d..d1920bf 100644 --- a/internal/logic/strategy/rule/up_date.go +++ b/internal/logic/strategy/rule/up_date.go @@ -17,5 +17,5 @@ func NewUpDate() *UpDate { } func (r *UpDate) Run(in string) *types.RuleResult { - return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 0, Desc: "暂不计算"} + return &types.RuleResult{Key: r.Key, Name: r.Name, Score: 1, Desc: "暂不计算"} }