gitee.com/quant1x/engine@v1.8.4/services/task_update_all.go (about) 1 package services 2 3 import ( 4 "gitee.com/quant1x/engine/cache" 5 "gitee.com/quant1x/engine/factors" 6 "gitee.com/quant1x/engine/storages" 7 "gitee.com/quant1x/exchange" 8 "time" 9 ) 10 11 var ( 12 // 非交易日每天更新一次 13 lastUpdateTime = "22:00:00.000" 14 // 交易日每天更新2次 15 allDateUpdateTimes = []string{"15:10:00.000", "18:10:00.000", lastUpdateTime} 16 ) 17 18 // 任务 - 更新全部数据 19 func jobUpdateAll() { 20 //funcName := "jobUpdateAll" 21 now := time.Now() 22 tm := now.Format(exchange.CN_SERVERTIME_FORMAT) 23 today := exchange.Today() 24 lastDate := exchange.LastTradeDate() 25 bUpdated := false 26 phase := "" 27 if today == lastDate { 28 for _, v := range allDateUpdateTimes { 29 if tm >= v { 30 phase = v 31 bUpdated = checkUpdateState(today, phase) 32 if bUpdated { 33 break 34 } 35 } 36 } 37 } else { 38 if tm >= lastUpdateTime { 39 phase = lastUpdateTime 40 bUpdated = checkUpdateState(today, phase) 41 } 42 } 43 if bUpdated && len(phase) > 0 { 44 factors.SwitchDate(cache.DefaultCanReadDate()) 45 updateAll() 46 doneUpdate(today, phase) 47 } 48 //else { 49 // logger.Infof("%s, 非全数据更新时段", funcName) 50 //} 51 } 52 53 func updateAll() { 54 barIndex := 1 55 currentDate := cache.DefaultCanUpdateDate() 56 cacheDate, featureDate := cache.CorrectDate(currentDate) 57 updateAllBaseData(barIndex, featureDate) 58 updateAllFeatures(barIndex+1, cacheDate, featureDate) 59 } 60 61 func updateAllBaseData(barIndex int, featureDate string) { 62 // 1. 获取全部注册的数据集插件 63 mask := cache.PluginMaskBaseData 64 plugins := cache.Plugins(mask) 65 // 2. 执行操作 66 storages.BaseDataUpdate(barIndex, featureDate, plugins, cache.OpUpdate) 67 } 68 69 func updateAllFeatures(barIndex int, cacheDate, featureDate string) { 70 // 1. 获取全部注册的数据集插件 71 mask := cache.PluginMaskFeature 72 plugins := cache.Plugins(mask) 73 storages.FeaturesUpdate(&barIndex, cacheDate, featureDate, plugins, cache.OpUpdate) 74 }