2 Star 3 Fork 10

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
task_features.go 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-23 08:30 . 调整调度任务代码结构
package services
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/engine/cachel5"
"gitee.com/quant1x/engine/storages"
"gitee.com/quant1x/gotdx/trading"
"gitee.com/quant1x/gox/logger"
"time"
)
var (
// 非交易日每天更新一次
lastUpdateTime = "22:00:00.000"
// 交易日每天更新2次
allDateUpdateTimes = []string{"15:10:00.000", "18:10:00.000", lastUpdateTime}
)
// 任务 - 更新全部数据
func jobUpdateAll() {
now := time.Now()
tm := now.Format(trading.CN_SERVERTIME_FORMAT)
today := trading.Today()
lastDate := trading.LastTradeDate()
bUpdated := false
phase := ""
if today == lastDate {
for _, v := range allDateUpdateTimes {
if tm >= v {
phase = v
bUpdated = checkUpdateState(today, phase)
if bUpdated {
break
}
}
}
} else {
if tm >= lastUpdateTime {
phase = lastUpdateTime
bUpdated = checkUpdateState(today, phase)
}
}
if bUpdated && len(phase) > 0 {
cachel5.SwitchDate(cache.DefaultCanReadDate())
updateAll()
doneUpdate(today, phase)
} else {
logger.Infof("非全数据更新时段")
}
}
func updateAll() {
barIndex := 1
currentDate := cache.DefaultCanUpdateDate()
cacheDate, featureDate := cache.CorrectDate(currentDate)
updateAllBaseData(barIndex, featureDate)
updateAllFeatures(barIndex+1, cacheDate, featureDate)
}
func updateAllBaseData(barIndex int, featureDate string) {
// 1. 获取全部注册的数据集插件
mask := cache.PluginMaskBaseData
plugins := cache.Plugins(mask)
// 2. 执行操作
storages.BaseDataUpdate(barIndex, featureDate, plugins, cache.OpUpdate)
}
func updateAllFeatures(barIndex int, cacheDate, featureDate string) {
// 1. 获取全部注册的数据集插件
mask := cache.PluginMaskFeature
//dataSetList := flash.DataSetList()
plugins := cache.Plugins(mask)
storages.FeaturesUpdate(&barIndex, cacheDate, featureDate, plugins, cache.OpUpdate)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.5.7

搜索帮助

344bd9b3 5694891 D2dac590 5694891