Files
gostock/internal/logic/restful/starter.go
yanweidong 0a0ae07a32 fix bug
2026-02-13 01:23:27 +08:00

62 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}