def onRspQryInvestorPosition(self, data: dict, error: dict, reqid: int, last: bool):
- """"""
- if not data:
- return
+ - # Check if contract data received
- if data["InstrumentID"] in symbol_exchange_map:
- # Get buffered position object
- # 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
+ - # For SHFE and INE position data update
- if position.exchange in [Exchange.SHFE, Exchange.INE]:
- if data["YdPosition"] and not data["TodayPosition"]:
- position.yd_volume = data["Position"]
- # For other exchange position data update
- else:
- position.yd_volume = data["Position"] - data["TodayPosition"]
+ - # Get contract size (spread contract has no size value)
- size = symbol_size_map.get(position.symbol, 0)
+
这里的逻辑处理似乎存在问题,这里为什么不是用累加 position.yd_volume,也就是 position.yd_volume += data["Position"] - data["TodayPosition"]