如题,使用no_ui,订阅行情rb2301和m2301合约,合约代码没有问题,然后间歇性的出现“行情订阅失败,找不到合约XXXX”问题。即有时订阅成功,有时订阅失败。尝试了在 main_engine.connect()之后加入了time.sleep(120),仍偶发性出现失败报错。不加sleep,也会成功。求教各位大佬,这是哪儿的问题,代码就是下边这个。
event_engine = EventEngine()
main_engine = MainEngine(event_engine)
main_engine.add_gateway(CtpGateway)
cta_engine = main_engine.add_app(CtaStrategyApp)
main_engine.write_log("主引擎创建成功")
log_engine = main_engine.get_engine("log")
event_engine.register(EVENT_CTA_LOG, log_engine.process_log_event)
main_engine.write_log("注册日志事件监听")
main_engine.connect(ctp_setting, "CTP")
main_engine.write_log("连接CTP接口")
# sleep(60)
cta_engine.init_engine()
main_engine.write_log("CTA策略初始化完成")
cta_engine.init_all_strategies()
sleep(60) # Leave enough time to complete strategy initialization
main_engine.write_log("CTA策略全部初始化")
cta_engine.start_all_strategies()
main_engine.write_log("CTA策略全部启动")