vnpy的converter里面,在update_trade中,是针对上期所优先平昨仓,再平今仓。但是calculate_frozen里面对仓位冻结都是优先冻结今仓,不足再冻结昨仓。如果是多头昨仓5手,多头今仓2手。平5手的时候下单手数会变成{多头平今2手,多头平昨3手},但是处理仓位冻结的时候,变成{多头昨仓冻结5手,多头今仓冻结0手}?
def calculate_frozen(self) -> None:
""""""
self.long_pos_frozen = 0
self.long_yd_frozen = 0
self.long_td_frozen = 0
self.short_pos_frozen = 0
self.short_yd_frozen = 0
self.short_td_frozen = 0
for order in self.active_orders.values():
# Ignore position open orders
if order.offset == Offset.OPEN:
continue
frozen: float = order.volume - order.traded
if order.direction == Direction.LONG:
if order.offset == Offset.CLOSETODAY:
self.short_td_frozen += frozen
elif order.offset == Offset.CLOSEYESTERDAY:
self.short_yd_frozen += frozen
elif order.offset == Offset.CLOSE:
self.short_td_frozen += frozen # 冻结时先冻结今仓,再冻结昨仓,不再匹配上期所模式?
if self.short_td_frozen > self.short_td:
self.short_yd_frozen += (self.short_td_frozen
- self.short_td)
self.short_td_frozen = self.short_td