2 Star 7 Fork 11

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
task_features.go 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
package services
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/engine/factors"
"gitee.com/quant1x/engine/storages"
"gitee.com/quant1x/gotdx/trading"
"time"
)
var (
// 非交易日每天更新一次
lastUpdateTime = "22:00:00.000"
// 交易日每天更新2次
allDateUpdateTimes = []string{"15:10:00.000", "18:10:00.000", lastUpdateTime}
)
// 任务 - 更新全部数据
func jobUpdateAll() {
//funcName := "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 {
factors.SwitchDate(cache.DefaultCanReadDate())
updateAll()
doneUpdate(today, phase)
}
//else {
// logger.Infof("%s, 非全数据更新时段", funcName)
//}
}
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
v1.0.2

搜索帮助