VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 5
声望: 0

账户存在套利合约的情况下,例如 SPC c1905&cs1905,vnpy登陆时会一直提示 onRspQryInvestorPosition KeyError,无法进行后续操作。

\vnpy\gateway\ctp\ctp_gateway.py(489): onRspQryInvestorPosition
KeyError: ('SPC c1905&cs1905',)

Administrator
avatar
加入于:
帖子: 4502
声望: 321

收到,这是个bug,我们尽快修复

Member
avatar
加入于:
帖子: 187
声望: 55

这是查询持仓的回调函函数(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
© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】