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

     1  package services
     2  
     3  import (
     4  	"gitee.com/quant1x/engine/trader"
     5  	"gitee.com/quant1x/exchange"
     6  	"gitee.com/quant1x/gox/api"
     7  	"gitee.com/quant1x/gox/logger"
     8  	"gitee.com/quant1x/gox/runtime"
     9  )
    10  
    11  // 同步委托订单
    12  func jobSyncTraderOrders() {
    13  	defer runtime.IgnorePanic("")
    14  	// 非交易日直接退出
    15  	if !exchange.DateIsTradingDay() {
    16  		return
    17  	}
    18  	name := trader.GetOrderFilename()
    19  	// 检查文件最后修改时间, 如果文件存在, 且时间在收盘之后, 则跳过同步
    20  	stat, err := api.GetFileStat(name)
    21  	if err == nil && stat != nil {
    22  		modTime := stat.LastWriteTime.Format(exchange.CN_SERVERTIME_FORMAT)
    23  		if modTime >= exchange.CN_CallAuctionPmEnd {
    24  			return
    25  		}
    26  	}
    27  	logger.Info("同步交易订单...")
    28  	defer logger.Info("同步交易订单...OK")
    29  	list, err := trader.QueryOrders()
    30  	if err != nil || len(list) == 0 {
    31  		logger.Info("同步交易订单...今日未操作")
    32  		return
    33  	}
    34  	_ = api.SlicesToCsv(name, list)
    35  }