[Mod] initialize LegData with position when created

This commit is contained in:
vn.py 2019-10-08 17:00:09 +08:00
parent 70b589ed52
commit 5aadb46bef

View File

@ -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(