From d98163f03463fb9a1bccb72bde9ff60c580e775d Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 4 Jan 2018 11:38:42 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E5=A2=9E=E5=8A=A0IB=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E7=8E=B0=E8=B4=A7=E8=B4=B5=E9=87=91=E5=B1=9E=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/ibGateway/ibGateway.py | 4 +++- vnpy/trader/uiBasicWidget.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/gateway/ibGateway/ibGateway.py b/vnpy/trader/gateway/ibGateway/ibGateway.py index 6104f002..9c6c251e 100644 --- a/vnpy/trader/gateway/ibGateway/ibGateway.py +++ b/vnpy/trader/gateway/ibGateway/ibGateway.py @@ -69,6 +69,7 @@ productClassMap[PRODUCT_FUTURES] = 'FUT' productClassMap[PRODUCT_OPTION] = 'OPT' productClassMap[PRODUCT_FOREX] = 'CASH' productClassMap[PRODUCT_INDEX] = 'IND' +productClassMap[PRODUCT_SPOT] = 'CMDTY' productClassMapReverse = {v:k for k,v in productClassMap.items()} # 期权类型映射 @@ -363,7 +364,8 @@ class IbWrapper(IbApi): tick.__setattr__(key, price) # IB的外汇行情没有成交价和时间,通过本地计算生成,同时立即推送 - if self.tickProductDict[tickerId] == PRODUCT_FOREX: + p = self.tickProductDict[tickerId] + if p == PRODUCT_FOREX or p == PRODUCT_SPOT: tick.lastPrice = (tick.bidPrice1 + tick.askPrice1) / 2 dt = datetime.now() tick.time = dt.strftime('%H:%M:%S.%f') diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 03d68d7d..3c1e4608 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -697,7 +697,8 @@ class TradingWidget(QtWidgets.QFrame): PRODUCT_EQUITY, PRODUCT_FUTURES, PRODUCT_OPTION, - PRODUCT_FOREX] + PRODUCT_FOREX, + PRODUCT_SPOT] gatewayList = ['']