使用bg生成5分钟的k线,查看打印发现推送过来的时候都迟了4分钟,15点25分的5分钟k线在15点29分和1分钟k线一起推送过来
1minbar: BarData(gateway_name='BINANCES', symbol='ETHUSDT', exchange=<Exchange.BINANCE: 'BINANCE'>, datetime=datetime.datetime(2022, 3, 14, 15, 28, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), interval=<Interval.MINUTE: '1m'>, volume=283.872999999905, turnover=0, open_interest=0, open_price=2575.8, high_price=2576.22, low_price=2575.05, close_price=2575.33)
5minbar: BarData(gateway_name='BINANCES', symbol='ETHUSDT', exchange=<Exchange.BINANCE: 'BINANCE'>, datetime=datetime.datetime(2022, 3, 14, 15, 25, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), interval=None, volume=1927.7130000002217, turnover=0, open_interest=0, open_price=2575.56, high_price=2577.6, low_price=2574.08, close_price=2576.01)
1minbar: BarData(gateway_name='BINANCES', symbol='ETHUSDT', exchange=<Exchange.BINANCE: 'BINANCE'>, datetime=datetime.datetime(2022, 3, 14, 15, 29, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), interval=<Interval.MINUTE: '1m'>, volume=580.9940000001807, turnover=0, open_interest=0, open_price=2575.33, high_price=2576.24, low_price=2574.08, close_price=2576.01)
1minbar: BarData(gateway_name='BINANCES', symbol='ETHUSDT', exchange=<Exchange.BINANCE: 'BINANCE'>, datetime=datetime.datetime(2022, 3, 14, 15, 30, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), interval=<Interval.MINUTE: '1m'>, volume=1220.7879999999423, turnover=0, open_interest=0, open_price=2576.01, high_price=2579.58, low_price=2575.9, close_price=2579.11)
1minbar: BarData(gateway_name='BINANCES', symbol='ETHUSDT', exchange=<Exchange.BINANCE: 'BINANCE'>, datetime=datetime.datetime(2022, 3, 14, 15, 31, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>), interval=<Interval.MINUTE: '1m'>, volume=526.2530000000261, turnover=0, open_interest=0, open_price=2579.11, high_price=2579.32, low_price=2576.55, close_price=2579.31)
查看代码发现是这里控制的,(29 + 1) % 5 == True才会调用slef.on_window_bar把生成的25分的5分钟k线推过来
# Check if window bar completed
if not (bar.datetime.minute + 1) % self.window:
self.on_window_bar(self.window_bar)
self.window_bar = None
想问一下,这里的5分钟k线不是应该在25分的1分钟k线生成后就能计算出来然后推送吗?为什么要等4分钟呢