From 2322406a931926e186afc7a0b23dd199c66681a3 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 19 Sep 2019 16:07:32 +0800 Subject: [PATCH] [Fix] only subscribe if contract data found --- vnpy/app/spread_trading/engine.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vnpy/app/spread_trading/engine.py b/vnpy/app/spread_trading/engine.py index 87310395..837d299e 100644 --- a/vnpy/app/spread_trading/engine.py +++ b/vnpy/app/spread_trading/engine.py @@ -221,11 +221,12 @@ class SpreadDataEngine: # Subscribe market data contract = self.main_engine.get_contract(vt_symbol) - req = SubscribeRequest( - contract.symbol, - contract.exchange - ) - self.main_engine.subscribe(req, contract.gateway_name) + if contract: + req = SubscribeRequest( + contract.symbol, + contract.exchange + ) + self.main_engine.subscribe(req, contract.gateway_name) return leg