diff --git a/cmd/selector/main.go b/cmd/selector/main.go index bd63206..a93ac1b 100644 --- a/cmd/selector/main.go +++ b/cmd/selector/main.go @@ -6,8 +6,8 @@ import ( "git.apinb.com/quant/gostock/internal/config" "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/logic/types" "git.apinb.com/quant/gostock/internal/models" "github.com/gocarina/gocsv" @@ -21,41 +21,42 @@ func main() { log.Println("Hello Cli!") config.New(ServiceKey) impl.NewImpl() - - 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) - stratRule.RunST(strategy.Cache[code].Basic.Name) - stratRule.RunIndustry(strategy.Cache[code].Basic.Industry) - stratRule.RunPrice(code) - stratRule.RunAmount(code) - stratRule.RunRoe(code) - stratRule.RunRsi(code) - - // 过滤无需AI分析 - if model.StScore > 0 && model.IndustryScore > 0 && model.GtPrice > 0 && model.GtAmount > 0 && model.GtRoe > 0 && model.ScoreRsi > 0 { - model.AiScore = 0 // 待分析 - } else { - model.AiScore = -2 - model.AddDesc("无需AI分析") - } - } - model.Save() - } - strategy.BootAiStart("selector", models.GetYmd()) + mock.Run("selector", models.GetYmd()) } -func ai() { - log.Println("Hello Cli!") - config.New(ServiceKey) - impl.NewImpl() +// func main() { +// log.Println("Hello Cli!") +// config.New(ServiceKey) +// impl.NewImpl() -} +// 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) +// stratRule.RunST(strategy.Cache[code].Basic.Name) +// stratRule.RunIndustry(strategy.Cache[code].Basic.Industry) +// stratRule.RunPrice(code) +// stratRule.RunAmount(code) +// stratRule.RunRoe(code) +// stratRule.RunRsi(code) + +// // 过滤无需AI分析 +// if model.StScore > 0 && model.IndustryScore > 0 && model.GtPrice > 0 && model.GtAmount > 0 && model.GtRoe > 0 && model.ScoreRsi > 0 { +// model.AiScore = 0 // 待分析 +// } else { +// model.AiScore = -2 +// model.AddDesc("无需AI分析") +// } +// } +// model.Save() +// } + +// strategy.BootAiStart("selector", models.GetYmd()) +// } func main3() { log.Println("Hello Cli!") diff --git a/internal/logic/mock/order.go b/internal/logic/mock/order.go index e1314be..3aeeebe 100644 --- a/internal/logic/mock/order.go +++ b/internal/logic/mock/order.go @@ -86,8 +86,8 @@ func Report() { }) } - // 3.判断盈亏超过20%,才确定平仓 - if pnlRate >= 20 { + // 3.判断盈亏超过10%,才确定平仓 + if pnlRate >= 10 { impl.DBService.Model(&models.MockPosition{}).Where("id=?", p.ID).Updates(map[string]any{ "close_price": newClosePrice, "pnl": pnl, diff --git a/internal/logic/restful/starter.go b/internal/logic/restful/starter.go index 1357774..1b42cdd 100644 --- a/internal/logic/restful/starter.go +++ b/internal/logic/restful/starter.go @@ -3,6 +3,7 @@ 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" @@ -33,10 +34,16 @@ func Starter(ctx *gin.Context) { 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).Update("ai_score", 0) + strategy.BootAiStart("selector", ymd) log.Println("Strategy END.") mock.Run("selector", ymd) diff --git a/internal/logic/strategy/ai.go b/internal/logic/strategy/ai.go index 7f3085a..74c735a 100644 --- a/internal/logic/strategy/ai.go +++ b/internal/logic/strategy/ai.go @@ -36,7 +36,7 @@ func AiAnalysis(code string) (map[string]any, error) { prompt += string(content) chatReq := &request.ChatCompletionsRequest{ - Model: deepseek.DEEPSEEK_REASONER_MODEL, + Model: deepseek.DEEPSEEK_CHAT_MODEL, Stream: false, Messages: []*request.Message{ { diff --git a/internal/models/money_total.go b/internal/models/money_total.go new file mode 100644 index 0000000..fa74ab3 --- /dev/null +++ b/internal/models/money_total.go @@ -0,0 +1,17 @@ +package models + +// 资金流数据模型 +type MoneyTotal struct { + ID uint `gorm:"primarykey"` + Code string // 股票代码 + Last1DayMfAmount float64 // 最近1天净流入额(万元) + Last3DayMfAmount float64 // 最近3天净流入额(万元) + Last1DayTotalAmount float64 // 最近1天中大单总流入额(万元) + Last3DayTotalAmount float64 // 最近3天中大单总流入额(万元) + IsGreaterPervious bool // 是否比上一日大单流入额多 +} + +// TableName 设置表名 +func (MoneyTotal) TableName() string { + return "money_total" +} diff --git a/scripts/build.sh b/scripts/build.sh index 8651d84..f3017be 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,4 +3,7 @@ GOARCH=amd64 GOOS=linux go build -o ../builds/gostock ./cmd/main/main.go nohup ./gostock > /data/app/logs/gostock.log 2>&1 & -cat /data/app/logs/gostock.log \ No newline at end of file +cat /data/app/logs/gostock.log + + +GOARCH=amd64 GOOS=linux go build -o ../builds/ai ./cmd/selector/main.go \ No newline at end of file