from tqsdk import TqApi, TqSim,TqBacktest,TargetPosTask
import datetime
import sys
async def task(symbol):
quote = api.get_quote(symbol)
klines = api.get_kline_serial(symbol,60,data_length=100)
async with api.register_update_notify(quote) as update_chan:
async for _ in update_chan:
if api.is_changing(klines.iloc[-1], “datetime”):
print(symbol)#打印变动合约名称
api = TqApi(TqSim(),backtest=TqBacktest(datetime.date(2019,7,1),datetime.date(2019,7,2)))
lst = [v[“underlying_symbol”] for k,v in api._data[“quotes”].items() if k.startswith(“KQ.m”)]
for i in lst:
api.create_task(task(i))
#print(i)
while True:
api.wait_update()
老板,帮看一下上面这段代码,我想用协程监控所有合约的变化,按我的想法是要用上面这段代码一直不停的打印K线在变化的合约代码,
但运行后怎么一会就结束退出了?也没提示错误.
好了,谢谢