gitee.com/quant1x/engine@v1.8.4/services/task_update_snapshot.go (about)

     1  package services
     2  
     3  import (
     4  	"gitee.com/quant1x/engine/models"
     5  	"gitee.com/quant1x/exchange"
     6  	"gitee.com/quant1x/gox/logger"
     7  	"gitee.com/quant1x/gox/runtime"
     8  	"time"
     9  )
    10  
    11  // 任务 - 更新快照
    12  func jobUpdateSnapshot() {
    13  	tm := time.Now()
    14  	updateInRealTime, status := exchange.CanUpdateInRealtime(tm)
    15  	// 交易时间更新数据
    16  	if updateInRealTime && (IsTrading(status) || exchange.CheckCallAuctionClose(tm)) {
    17  		realtimeUpdateSnapshot()
    18  	} else {
    19  		if runtime.Debug() {
    20  			realtimeUpdateSnapshot()
    21  		}
    22  	}
    23  }
    24  
    25  // 更新快照
    26  func realtimeUpdateSnapshot() {
    27  	logger.Infof("同步snapshot...")
    28  	models.SyncAllSnapshots(nil)
    29  	logger.Infof("同步snapshot...OK")
    30  }