From 71ae09a89bacf6af64f4c08347b888475cf16ce1 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 31 Oct 2017 21:40:20 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E5=A2=9E=E5=8A=A0CTP=E8=A1=8C=E6=83=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E4=BA=8E=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E6=89=80=E6=95=B0=E6=8D=AE=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E8=A1=8C=E6=83=85=E6=8E=A8=E9=80=81=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/ctpGateway/ctpGateway.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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']