From 2100318dd942dd27288ecec0d349a229894bce8a Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Thu, 1 Jun 2017 23:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B4=E8=BE=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9LME=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4BasicMonitor=E7=9A=84Resize=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/shzdGateway/shzdGateway.py | 6 +++++- vnpy/trader/language/chinese/constant.py | 2 ++ vnpy/trader/language/english/constant.py | 1 + vnpy/trader/uiBasicWidget.py | 8 +++++++- vnpy/trader/vtEngine.py | 3 +++ vnpy/trader/vtMain.py | 18 +++--------------- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/vnpy/trader/gateway/shzdGateway/shzdGateway.py b/vnpy/trader/gateway/shzdGateway/shzdGateway.py index 02b22041..a56d2d42 100644 --- a/vnpy/trader/gateway/shzdGateway/shzdGateway.py +++ b/vnpy/trader/gateway/shzdGateway/shzdGateway.py @@ -41,6 +41,7 @@ exchangeMap = {} exchangeMap[EXCHANGE_HKEX] = 'HKEX' exchangeMap[EXCHANGE_CME] = 'CME' exchangeMap[EXCHANGE_ICE] = 'ICE' +exchangeMap[EXCHANGE_LME] = 'LME' exchangeMapReverse = {v:k for k,v in exchangeMap.items()} # 产品类型映射 @@ -283,7 +284,10 @@ class ShzdGatewayApi(ShzdApi): tick.vtSymbol = '.'.join([tick.symbol, tick.exchange]) tick.volume = int(data['513']) - tick.openInterest = int(data['514']) + + # LME行情没有持仓量数据 + if data['306'] != 'LME': + tick.openInterest = int(data['514']) dt = data['512'].split(' ') tick.time = dt[1] diff --git a/vnpy/trader/language/chinese/constant.py b/vnpy/trader/language/chinese/constant.py index 8f1a1c3e..53f53741 100644 --- a/vnpy/trader/language/chinese/constant.py +++ b/vnpy/trader/language/chinese/constant.py @@ -67,6 +67,7 @@ EXCHANGE_NONE = '' # 空交易所 EXCHANGE_HKEX = 'HKEX' # 港交所 EXCHANGE_HKFE = 'HKFE' # 香港期货交易所 + EXCHANGE_SMART = 'SMART' # IB智能路由(股票、期权) EXCHANGE_NYMEX = 'NYMEX' # IB 期货 EXCHANGE_GLOBEX = 'GLOBEX' # CME电子交易平台 @@ -74,6 +75,7 @@ EXCHANGE_IDEALPRO = 'IDEALPRO' # IB外汇ECN EXCHANGE_CME = 'CME' # CME交易所 EXCHANGE_ICE = 'ICE' # ICE交易所 +EXCHANGE_LME = 'LME' # LME交易所 EXCHANGE_OANDA = 'OANDA' # OANDA外汇做市商 EXCHANGE_OKCOIN = 'OKCOIN' # OKCOIN比特币交易所 diff --git a/vnpy/trader/language/english/constant.py b/vnpy/trader/language/english/constant.py index dae1c9bf..bb0b8e03 100644 --- a/vnpy/trader/language/english/constant.py +++ b/vnpy/trader/language/english/constant.py @@ -74,6 +74,7 @@ EXCHANGE_IDEALPRO = 'IDEALPRO' # IB外汇ECN EXCHANGE_CME = 'CME' # CME交易所 EXCHANGE_ICE = 'ICE' # ICE交易所 +EXCHANGE_LME = 'LME' # LME交易所 EXCHANGE_OANDA = 'OANDA' # OANDA外汇做市商 EXCHANGE_OKCOIN = 'OKCOIN' # OKCOIN比特币交易所 diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 9df85770..6ca40d98 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -217,6 +217,9 @@ class BasicMonitor(QtWidgets.QTableWidget): # 监控的事件类型 self.eventType = '' + # 列宽调整状态(只在第一次更新数据时调整一次列宽) + self.columnResized = False + # 字体 self.font = None @@ -345,7 +348,9 @@ class BasicMonitor(QtWidgets.QTableWidget): self.setItem(0, n, cell) # 调整列宽 - self.resizeColumns() + if not self.columnResized: + self.resizeColumns() + self.columnResized = True # 重新打开排序 if self.sorting: @@ -677,6 +682,7 @@ class TradingWidget(QtWidgets.QFrame): EXCHANGE_ICE, EXCHANGE_CME, EXCHANGE_NYMEX, + EXCHANGE_LME, EXCHANGE_GLOBEX, EXCHANGE_IDEALPRO] diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index b8bc63dc..a9d79d6a 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -1,5 +1,6 @@ # encoding: UTF-8 +import os import shelve from collections import OrderedDict from datetime import datetime @@ -277,6 +278,8 @@ class MainEngine(object): class DataEngine(object): """数据引擎""" contractFileName = 'ContractData.vt' + path = os.path.abspath(os.path.dirname(__file__)) + contractFileName = os.path.join(path, 'temp', contractFileName) #---------------------------------------------------------------------- def __init__(self, eventEngine): diff --git a/vnpy/trader/vtMain.py b/vnpy/trader/vtMain.py index f9826670..97e3f129 100644 --- a/vnpy/trader/vtMain.py +++ b/vnpy/trader/vtMain.py @@ -13,13 +13,9 @@ from vnpy.trader.uiQt import qApp from vnpy.trader.uiMainWindow import MainWindow # 加载底层接口 -from vnpy.trader.gateway import (ctpGateway, femasGateway, ksotpGateway, - qdpGateway, xspeedGateway, - cshshlpGateway, ltsGateway, - ksgoldGateway, sgitGateway, - oandaGateway, ibGateway, shzdGateway, - huobiGateway, okcoinGateway, lhangGateway, - windGateway) +from vnpy.trader.gateway import (ctpGateway, femasGateway, xspeedGateway, + sgitGateway, oandaGateway, ibGateway, + shzdGateway, huobiGateway, okcoinGateway) # 加载上层应用 from vnpy.trader.app import (riskManager, dataRecorder, @@ -38,20 +34,13 @@ def main(): # 添加交易接口 me.addGateway(ctpGateway) me.addGateway(femasGateway) - me.addGateway(ksotpGateway) - me.addGateway(qdpGateway) me.addGateway(xspeedGateway) - me.addGateway(cshshlpGateway) - me.addGateway(ltsGateway) - me.addGateway(ksgoldGateway) me.addGateway(sgitGateway) me.addGateway(oandaGateway) me.addGateway(ibGateway) me.addGateway(shzdGateway) me.addGateway(huobiGateway) me.addGateway(okcoinGateway) - me.addGateway(lhangGateway) - me.addGateway(windGateway) # 添加上层应用 me.addApp(riskManager) @@ -66,6 +55,5 @@ def main(): sys.exit(qApp.exec_()) - if __name__ == '__main__': main()