import datetime,time import numpy as np import talib as ta from tqsdk import TqApi, TqBacktest,TqAccount,TqSim api = TqApi(backtest=TqBacktest(start_dt=datetime.date(2019, 10, 1), end_dt=datetime.date(2020, 5, 27))) _kline = api.get_kline_serial('CZCE.AP010',60*60*24,data_length=99) while True: api.wait_update() if api.is_changing(_kline.iloc[-1]): _len = len(_kline['datetime'][_kline['datetime'] > 0]) _dt = _kline['datetime'].iloc[-1] _dt = datetime.datetime.fromtimestamp(_dt/1e9) if _len < 77: print('数据不足[%s]:%s,id:%s'%(_dt,_len,_kline['id'].iloc[-1])) continue else: print(_dt)