f
This commit is contained in:
23
internal/logic/restful/recommend.go
Normal file
23
internal/logic/restful/recommend.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package restful
|
||||
|
||||
import (
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/logic/strategy"
|
||||
"git.apinb.com/quant/gostock/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Recommend(ctx *gin.Context) {
|
||||
ymd := lastYmd()
|
||||
strategy.TotalScore(ymd)
|
||||
var stocks []string
|
||||
impl.DBService.Model(&models.StratModel{}).Where("total_score>?", 0).Pluck("code", &stocks)
|
||||
ctx.JSON(200, stocks)
|
||||
return
|
||||
}
|
||||
func lastYmd() int {
|
||||
var ymd int
|
||||
sql := "select ymd from strat_model sm group by ymd order by ymd desc limit 1"
|
||||
impl.DBService.Raw(sql).Scan(&ymd)
|
||||
return ymd
|
||||
}
|
||||
@@ -35,8 +35,9 @@ func Starter(ctx *gin.Context) {
|
||||
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 {
|
||||
if model.UpDateDay > 360 && model.StScore > 0 && model.IndustryScore > 1 && model.GtPrice > 0 && model.GtAmount > 0 && model.GtRoe > 0 && model.ScoreRsi > 0 {
|
||||
model.AiScore = 0 // 待分析
|
||||
model.TotalScore = float64(model.IndustryScore + model.StScore + model.GtPrice + model.GtAmount + model.GtRoe + model.ScoreRsi)
|
||||
model.RecommendDesc = "Rule规则"
|
||||
} else {
|
||||
model.AiScore = -2
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
MinRoe float64 = 0
|
||||
MinRoe float64 = 5
|
||||
)
|
||||
|
||||
func (r *RuleFactory) RunRoe(code string) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
offset = 0 // 偏移量
|
||||
offset = 1 // 偏移量
|
||||
)
|
||||
|
||||
type StockArgConf struct {
|
||||
|
||||
@@ -5,14 +5,12 @@ import (
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/models"
|
||||
)
|
||||
|
||||
func TotalScore(ymd int) {
|
||||
log.Println("Total Score", ymd)
|
||||
impl.DBService.Model(&models.StratModel{}).Where("ymd=?", ymd).Update("total_score", 0)
|
||||
where := "where up_date_day>180 and st_score>0 and gt_amount>0 and gt_price>0 and gt_roe>0 and score_rsi>0 and ai_score>=5 and ymd=" + utils.Int2String(ymd)
|
||||
sql := "update strat_model set total_score=industry_score+val_roe+ai_score " + where
|
||||
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
|
||||
|
||||
log.Println("SQL:", sql)
|
||||
err := impl.DBService.Exec(sql).Error
|
||||
|
||||
@@ -44,7 +44,7 @@ type StratModel struct {
|
||||
AiRisk string
|
||||
|
||||
TotalDesc string
|
||||
TotalScore float64
|
||||
TotalScore float64 `gorm:"default:0"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user