From 5aadb46bef00f3440e03d1dfd69eb33910395de5 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 8 Oct 2019 17:00:09 +0800 Subject: [PATCH] [Mod] initialize LegData with position when created --- vnpy/app/spread_trading/engine.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vnpy/app/spread_trading/engine.py b/vnpy/app/spread_trading/engine.py index 837d299e..433eb19d 100644 --- a/vnpy/app/spread_trading/engine.py +++ b/vnpy/app/spread_trading/engine.py @@ -228,6 +228,14 @@ class SpreadDataEngine: ) self.main_engine.subscribe(req, contract.gateway_name) + # Initialize leg position + for direction in Direction: + vt_positionid = f"{vt_symbol}.{direction.value}" + position = self.main_engine.get_position(vt_positionid) + + if position: + leg.update_position(position) + return leg def add_spread(