41 lines
764 B
Go
41 lines
764 B
Go
package strategy
|
|
|
|
import (
|
|
"log"
|
|
"sync"
|
|
|
|
"git.apinb.com/quant/gostock/internal/impl"
|
|
"git.apinb.com/quant/gostock/internal/models"
|
|
)
|
|
|
|
func Boot() {
|
|
InitCacheByAll()
|
|
}
|
|
|
|
func BootAiStart(key string, ymd int) {
|
|
var datas []models.StratModel
|
|
err := impl.DBService.Where("strat_key=? and ymd=? and ai_score=0", key, ymd).Find(&datas).Error
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
for _, row := range datas {
|
|
wg.Add(1)
|
|
go BootAiTask(row.ID, row.Code, &wg)
|
|
}
|
|
|
|
wg.Wait()
|
|
}
|
|
|
|
func BootAiTask(id uint, code string, wg *sync.WaitGroup) {
|
|
defer wg.Done()
|
|
result, err := AiAnalysis(code)
|
|
if err != nil {
|
|
log.Println("ERROR BootAiTask", err.Error())
|
|
return
|
|
}
|
|
impl.DBService.Model(&models.StratModel{}).Where("id=?", id).Updates(result)
|
|
}
|