fix bug
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user