2 Star 7 Fork 11

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
task_realtime_kline.go 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
package services
import (
"gitee.com/quant1x/engine/datasource/base"
"gitee.com/quant1x/engine/market"
"gitee.com/quant1x/engine/models"
"gitee.com/quant1x/exchange"
"gitee.com/quant1x/gox/coroutine"
"gitee.com/quant1x/gox/logger"
"gitee.com/quant1x/gox/progressbar"
"gitee.com/quant1x/gox/runtime"
)
// 任务 - 实时更新K线
func jobRealtimeKLine() {
funcName := "jobRealtimeKLine"
updateInRealTime, status := exchange.CanUpdateInRealtime()
// 14:30:00~15:01:00之间更新数据
if updateInRealTime && IsTrading(status) {
realtimeUpdateOfKLine()
} else {
if runtime.Debug() {
realtimeUpdateOfKLine()
} else {
logger.Infof("%s, 非尾盘交易时段: %d", funcName, status)
}
}
}
// 更新K线
func realtimeUpdateOfKLine() {
defer runtime.IgnorePanic()
barIndex := barIndexRealtimeKLine
allCodes := market.GetCodeList()
wg := coroutine.NewRollingWaitGroup(5)
bar := progressbar.NewBar(barIndex, "执行[实时更新K线]", len(allCodes))
for _, code := range allCodes {
updateKLine := func(waitGroup *coroutine.RollingWaitGroup, securityCode string) {
defer waitGroup.Done()
bar.Add(1)
snapshot := models.GetTickFromMemory(securityCode)
if snapshot != nil {
base.BasicKLineForSnapshot(*snapshot)
}
}
wg.Add(1)
go updateKLine(wg, code)
}
wg.Wait()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.2.8

搜索帮助