api = TqApi(backtest=TqBacktest(start_dt=date(2020,2,27), end_dt=date(2020,2,28))) klines = api.get_kline_serial("KQ.m@SHFE.rb", 60) while True: api.wait_update() if api.is_changing(klines): print('{} / - {}'.format(time_to_str(klines.iloc[-1]['datetime']), klines.iloc[-1]['volume']))
因为kline在刚刚刷新时这根k线的成交量就是伪0呀,同时回测时kline只会刷新两次,在生成时一次,结束时一次
具体的回测行情推进规则可见https://doc.shinnytech.com/tqsdk/latest/usage/backtest.html#backtest-rule