VeighNa量化社区
你的开源社区量化交易平台 | vn.py | vnpy
Member
avatar
加入于:
帖子: 1
声望: 0

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"]
Member
avatar
加入于:
帖子: 1867
声望: 142

上期所的今昨仓数据返回机制和其他交易所不一样,自己打印下print data看看就知道了

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

沪公网安备 31011502017034号

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