账户存在套利合约的情况下,例如 SPC c1905&cs1905,vnpy登陆时会一直提示 onRspQryInvestorPosition KeyError,无法进行后续操作。
\vnpy\gateway\ctp\ctp_gateway.py(489): onRspQryInvestorPosition
KeyError: ('SPC c1905&cs1905',)
账户存在套利合约的情况下,例如 SPC c1905&cs1905,vnpy登陆时会一直提示 onRspQryInvestorPosition KeyError,无法进行后续操作。
\vnpy\gateway\ctp\ctp_gateway.py(489): onRspQryInvestorPosition
KeyError: ('SPC c1905&cs1905',)
收到,这是个bug,我们尽快修复
这是查询持仓的回调函函数(onRspQryInvestorPosition)报错。
查看原函数后,发现是data['InstrumentID']这里插入数据报错, InstrumentID仅仅指的是合约代码,不包含交易所代码。所以插入套利合约(SPC c1905&cs1905)会报错。这个bug我们尽量修复一下
def onRspQryInvestorPosition(self, data: dict, error: dict, reqid: int, last: bool):
""""""
if not data:
return
# Get buffered position object
key = f"{data['InstrumentID'], data['PosiDirection']}"
position = self.positions.get(key, None)
if not position:
position = PositionData(
symbol=data["InstrumentID"],
exchange=symbol_exchange_map[data["InstrumentID"]],
direction=DIRECTION_CTP2VT[data["PosiDirection"]],
gateway_name=self.gateway_name
)
self.positions[key] = position