如何每天发送多个主力合约的目标仓位进行回测(其中主力合约和目标仓位随着日期会变化)?谢谢!
async def demo(SYMBOL, TargetPos):
quote = await api.get_quote(SYMBOL) # 支持 await 异步,这里会订阅合约,等到收到合约行情才返回
target_pos = TargetPosTask(api, SYMBOL)
async with api.register_update_notify() as update_chan:
async for _ in update_chan:
if api.is_changing(quote):
print(SYMBOL, TargetPos, quote.datetime[:10], quote.datetime[10:], quote.last_price)
target_pos.set_target_volume(TargetPos)