package restful import ( "log" "git.apinb.com/quant/gostock/internal/impl" "git.apinb.com/quant/gostock/internal/logic/mock" "git.apinb.com/quant/gostock/internal/logic/strategy" "git.apinb.com/quant/gostock/internal/logic/strategy/rule" "git.apinb.com/quant/gostock/internal/models" "github.com/gin-gonic/gin" ) func Starter(ctx *gin.Context) { log.Println("Strategy START.") ymd := models.GetYmd() for _, code := range strategy.GetStocks() { strategy.InitCacheByCode(code) model := models.NewStratModel("selector", code, ymd) stratRule := rule.NewRule(model) { // 规则:上市时间 stratRule.RunUpDate(strategy.Cache[code].Basic.ListDate) // 规则:是否是ST stratRule.RunST(strategy.Cache[code].Basic.Name) // 规则:行业,剔除夕阳和中性行业 stratRule.RunIndustry(strategy.Cache[code].Basic.Industry) // 规则:最近20天每天最低价高于5元 stratRule.RunPrice(code) // 规则:每天交易额超过10亿 stratRule.RunAmount(code) // 规则:ROE 市盈率必须为正 stratRule.RunRoe(code) // 规则:RSI指标贴近下轨并成上涨趋势 stratRule.RunRsi(code) // 满足以上规则在让Deepseek分析 if model.UpDateDay > 180 && model.StScore > 0 && model.IndustryScore > 1 && model.GtPrice > 0 && model.GtAmount > 0 && model.GtRoe > 0 && model.ScoreRsi > 0 { model.AiScore = 0 // 待分析 model.RecommendDesc = "Rule规则" } else { model.AiScore = -2 model.AddDesc("无需AI分析") } } model.Save() } // 加入资金流向特大的标的 var codes []string impl.DBService.Model(&models.MoneyTotal{}).Where("is_greater_pervious = ? and last3_day_mf_amount>?", true, 100000).Pluck("code", &codes) impl.DBService.Model(&models.StratModel{}).Where("ai_score=-2 and code in ?", codes).Updates(map[string]any{"ai_score": 0, "recommend_desc": "资金流向"}) // Todo: 舆论分析得出的标的 // AI分析:根据基本资料,过去200交易日的数据,200日的财务指标,3年周报给出得分 strategy.BootAiStart("selector", ymd) log.Println("Strategy END.") mock.Run("selector", ymd) }