From f29265c0e40343cb6c0aab23cede244e93b7253b Mon Sep 17 00:00:00 2001 From: yanweidonog Date: Wed, 25 Feb 2026 23:07:10 +0800 Subject: [PATCH] fix bug --- internal/logic/mock/order.go | 9 ++++++++- internal/logic/restful/starter.go | 7 ++++++- internal/logic/strategy/total.go | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/logic/mock/order.go b/internal/logic/mock/order.go index 1e6ea46..c3b548e 100644 --- a/internal/logic/mock/order.go +++ b/internal/logic/mock/order.go @@ -12,7 +12,7 @@ import ( func Run(key string, ymd int) { log.Println("Run Mock Order.") var stocks []*models.StratModel - impl.DBService.Where("strat_key=? and ymd=? and rsi_score>0 and macd_score>0 ai_score>=?", key, ymd, 5).Find(&stocks) + impl.DBService.Where("strat_key=? and ymd=? and rsi_score>0 and macd_score>0 and ai_score>=?", key, ymd, 5).Find(&stocks) if len(stocks) == 0 { log.Println("No data to process.") return @@ -98,3 +98,10 @@ func Report() { } } } + +func IsPosition(code string) bool { + var cnt int64 + impl.DBService.Model(&models.MockPosition{}).Where("code=? and status=0", code).Count(&cnt) + + return cnt > 0 +} diff --git a/internal/logic/restful/starter.go b/internal/logic/restful/starter.go index 7d02c45..aa6d054 100644 --- a/internal/logic/restful/starter.go +++ b/internal/logic/restful/starter.go @@ -26,6 +26,12 @@ func Starter(ctx *gin.Context) { } for _, code := range strategy.GetStocks() { + // 验收是否已经持仓 + if mock.IsPosition(code) { + log.Printf("Position exists for %s, skip.", code) + continue + } + basic := strategy.GetBasic(code) model := models.NewStratModel("selector", code, ymd) stratRule := rule.NewRule(model) @@ -80,6 +86,5 @@ func Starter(ctx *gin.Context) { // AI分析:根据基本资料,过去200交易日的数据,200日的财务指标,3年财报给出得分 strategy.BootAiStart("selector", ymd) log.Println("Strategy END.") - strategy.TotalScore(ymd) mock.Run("selector", ymd) } diff --git a/internal/logic/strategy/total.go b/internal/logic/strategy/total.go index fafc151..012b808 100644 --- a/internal/logic/strategy/total.go +++ b/internal/logic/strategy/total.go @@ -10,7 +10,7 @@ import ( func TotalScore(ymd int) { log.Println("Total Score", ymd) where := " where up_date_day>360 and ymd=" + utils.Int2String(ymd) - sql := "update strat_model set total_score=industry_score+st_score+gt_amount+gt_price+gt_roe+score_rsi" + where + sql := "update strat_model set total_score=industry_score+st_score+gt_amount+gt_price+roe_score+rsi_score" + where log.Println("SQL:", sql) err := impl.DBService.Exec(sql).Error