diff --git a/vnpy/trader/gateway/ctpGateway/ctpGateway.py b/vnpy/trader/gateway/ctpGateway/ctpGateway.py index 3a8dcc47..e8490957 100644 --- a/vnpy/trader/gateway/ctpGateway/ctpGateway.py +++ b/vnpy/trader/gateway/ctpGateway/ctpGateway.py @@ -342,12 +342,17 @@ class CtpMdApi(MdApi): #---------------------------------------------------------------------- def onRtnDepthMarketData(self, data): """行情推送""" + # 过滤尚未获取合约交易所时的行情推送 + symbol = data['InstrumentID'] + if symbol not in symbolExchangeDict: + return + # 创建对象 tick = VtTickData() tick.gatewayName = self.gatewayName - tick.symbol = data['InstrumentID'] - tick.exchange = symbolExchangeDict.get(tick.symbol, EXCHANGE_UNKNOWN) + tick.symbol = symbol + tick.exchange = symbolExchangeDict[tick.symbol] tick.vtSymbol = tick.symbol #'.'.join([tick.symbol, tick.exchange]) tick.lastPrice = data['LastPrice']