vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 34
声望: 3

发送订单
第1 发单 cover_vt_orderid = self.cover(cover_price, abs(order_volume))
发单之后INFO信息会返回一个Order Object
第2 打印 self.write_log(f'买入平仓 , pos:{self.pos}, local_pos:{self.local_pos}, \
orderid:{cover_vt_orderid}, symbol:{self.vt_symbol}, price:{cover_price}, volume:{order_volume}')
返回信息 和打印信息如下:

2021-07-02 09:03:05,599  INFO: original_req:OrderRequest(symbol='SP jm2108&jm2110', exchange=<Exchange.DCE: 'DCE'>, direction=<Direction.LONG: '多'>, type=<OrderType.LIMIT: '限价'>, volume=1.0, price=116.5, offset=<Offset.CLOSE: '平'>, reference='')
2021-07-02 09:03:05,599  INFO: req_list:[OrderRequest(symbol='SP jm2108&jm2110', exchange=<Exchange.DCE: 'DCE'>, direction=<Direction.LONG: '多'>, type=<OrderType.LIMIT: '限价'>, volume=1.0, price=116.5, offset=<Offset.CLOSE: '平'>, reference='')]
2021-07-02 09:03:05,617  INFO: req:OrderRequest(symbol='SP jm2108&jm2110', exchange=<Exchange.DCE: 'DCE'>, direction=<Direction.LONG: '多'>, type=<OrderType.LIMIT: '限价'>, volume=1.0, price=116.5, offset=<Offset.CLOSE: '平'>, reference='')
2021-07-02 09:03:05,617  INFO: ex_long jm2108&jm2110: 买入平仓 , pos:50, local_pos:0,                         orderid:['CTP.6_1679360163_1'], symbol:SP jm2108&jm2110.DCE, price:116.5, volume:1

请问,怎么才能第一时间在策略的内部主动获取这个Order Object的信息
cover_vt_orderid = self.cover(cover_price, abs(order_volume))
譬如在上述发单命令之后,在策略的内部调用self.cta_engine.main_engine.get_order(cover_vt_orderid),获取不到这个order Object,得到的是 None

Administrator
avatar
加入于:
帖子: 4985
声望: 291

通过on_order回调函数获取是最快的了

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号