gitee.com/quant1x/engine@v1.8.4/services/services.go (about) 1 package services 2 3 import ( 4 "gitee.com/quant1x/exchange" 5 "gitee.com/quant1x/gox/logger" 6 ) 7 8 const ( 9 // CronTriggerNetwork 网络重置每天8点55分 10 CronTriggerNetwork = "55 8 * * *" 11 // CronTriggerInit 定制任务初始化cron定位9点 12 CronTriggerInit = "0 9 * * *" 13 // CronDefaultInterval 默认的执行频次 14 CronDefaultInterval = "@every 10s" 15 // CronTickInterval tick级别数据的更新频次 16 CronTickInterval = "@every 1s" 17 // 同步订单触发时间, 每交易日15点~23点的02分 18 cronSyncOrdersInterval = "2 15-23 * * *" 19 // cronMarginTrading 更新融资融券 20 cronMarginTrading = "5 9 * * *" 21 ) 22 23 const ( 24 barIndexUpdateSnapshot = 1 25 barIndexRealtimeKLine = 2 26 barIndexUpdateExchangeAndSnapshot = 3 27 ) 28 29 // 定时任务关键字 30 const ( 31 keyCronReset = "global_reset" // 全局重置 32 keyCronRealTimeKLine = "realtime_kline" // 实时更新K线 33 keyCronUpdateSnapshot = "update_snapshot" // 更新快照 34 keyCronUpdateMisc = "update_misc" // 更新misc 35 keyCronUpdateAll = "update_all" // 更新全部数据, 包括基础数据和特征数据 36 keyCronCookieCutterSell = "sell_117" // 一刀切卖出, one-size-fits-all 37 keyCronSyncQmtOrder = "sync_orders" // 同步订单 38 keyCronResetNetwork = "reset_network" // 重置网络 39 keyCronMarginTrading = "update_rzrq" // 更新融资融券 40 ) 41 42 func init() { 43 err := Register(keyCronResetNetwork, CronTriggerNetwork, jobResetNetwork) 44 if err != nil { 45 logger.Fatal(err) 46 } 47 // 定时重置缓存 48 err = Register(keyCronReset, CronTriggerInit, jobGlobalReset) 49 if err != nil { 50 logger.Fatal(err) 51 } 52 // 实时更新快照 53 err = Register(keyCronUpdateSnapshot, CronTickInterval, jobUpdateSnapshot) 54 if err != nil { 55 logger.Fatal(err) 56 } 57 // 更新misc特征数据 58 err = Register(keyCronUpdateMisc, CronTickInterval, jobUpdateMiscAndSnapshot) 59 if err != nil { 60 logger.Fatal(err) 61 } 62 63 // 实时更新K线 64 err = Register(keyCronRealTimeKLine, CronDefaultInterval, jobRealtimeKLine) 65 if err != nil { 66 logger.Fatal(err) 67 } 68 69 // 更新全部 70 err = Register(keyCronUpdateAll, CronDefaultInterval, jobUpdateAll) 71 if err != nil { 72 logger.Fatal(err) 73 } 74 75 // 一刀切卖出 76 err = Register(keyCronCookieCutterSell, CronDefaultInterval, jobOneSizeFitsAllSales) 77 if err != nil { 78 logger.Fatal(err) 79 } 80 // 同步QMT订单 81 err = Register(keyCronSyncQmtOrder, cronSyncOrdersInterval, jobSyncTraderOrders) 82 if err != nil { 83 logger.Fatal(err) 84 } 85 // 更新融资融券 86 err = Register(keyCronMarginTrading, cronMarginTrading, jobUpdateMarginTrading) 87 if err != nil { 88 logger.Fatal(err) 89 } 90 } 91 92 // IsTrading 状态是否交易中 93 func IsTrading(status int) bool { 94 if status == exchange.ExchangeTrading || status == exchange.ExchangeCallAuction { 95 return true 96 } 97 return false 98 }