From fe92850996bd7546687cfe85bd0b5678d5aa48cf Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 9 Jul 2017 23:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/VnTrader/VT_setting.json | 11 ++ vnpy/trader/app/dataRecorder/drEngine.py | 4 +- .../gateway/cshshlpGateway/cshshlpGateway.py | 8 +- vnpy/trader/gateway/ctpGateway/ctpGateway.py | 9 +- .../gateway/femasGateway/femasGateway.py | 8 +- .../gateway/huobiGateway/huobiGateway.py | 8 +- vnpy/trader/gateway/ibGateway/ibGateway.py | 8 +- .../gateway/ksgoldGateway/ksgoldGateway.py | 8 +- .../gateway/ksotpGateway/ksotpGateway.py | 8 +- .../gateway/lhangGateway/lhangGateway.py | 8 +- vnpy/trader/gateway/ltsGateway/ltsGateway.py | 8 +- .../gateway/oandaGateway/oandaGateway.py | 8 +- .../gateway/okcoinGateway/okcoinGateway.py | 8 +- vnpy/trader/gateway/qdpGateway/qdpGateway.py | 11 +- .../trader/gateway/sgitGateway/sgitGateway.py | 9 +- .../trader/gateway/shzdGateway/shzdGateway.py | 9 +- .../gateway/xspeedGateway/xspeedGateway.py | 11 +- vnpy/trader/ico/editor.ico | Bin 0 -> 67646 bytes vnpy/trader/language/chinese/text.py | 3 + vnpy/trader/language/english/text.py | 3 + vnpy/trader/uiBasicWidget.py | 98 +++++++++++++++++- vnpy/trader/uiMainWindow.py | 10 ++ vnpy/trader/vtFunction.py | 10 +- vnpy/trader/vtGlobal.py | 5 +- 24 files changed, 196 insertions(+), 77 deletions(-) create mode 100644 examples/VnTrader/VT_setting.json create mode 100644 vnpy/trader/ico/editor.ico diff --git a/examples/VnTrader/VT_setting.json b/examples/VnTrader/VT_setting.json new file mode 100644 index 00000000..c9bdcc0b --- /dev/null +++ b/examples/VnTrader/VT_setting.json @@ -0,0 +1,11 @@ +{ + "fontFamily": "微软雅黑", + "fontSize": 12, + + "mongoHost": "localhost", + "mongoPort": 27017, + "mongoLogging": true, + + "darkStyle": true, + "language": "chinese" +} \ No newline at end of file diff --git a/vnpy/trader/app/dataRecorder/drEngine.py b/vnpy/trader/app/dataRecorder/drEngine.py index ec4641c2..63a20e57 100644 --- a/vnpy/trader/app/dataRecorder/drEngine.py +++ b/vnpy/trader/app/dataRecorder/drEngine.py @@ -218,7 +218,9 @@ class DrEngine(object): bar = self.barDict[vtSymbol] # 如果第一个TICK或者新的一分钟 - if not bar.datetime or bar.datetime.minute != tick.datetime.minute: + if (not bar.datetime or + bar.datetime.minute != tick.datetime.minute or + bar.datetime.hour != tick.datetime.hour): if bar.vtSymbol: newBar = copy.copy(bar) self.insertData(MINUTE_DB_NAME, vtSymbol, newBar) diff --git a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py index 63fdf361..8e8689cb 100644 --- a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py +++ b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py @@ -92,15 +92,15 @@ class CshshlpGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/ctpGateway/ctpGateway.py b/vnpy/trader/gateway/ctpGateway/ctpGateway.py index 129bcd30..f9390b2a 100644 --- a/vnpy/trader/gateway/ctpGateway/ctpGateway.py +++ b/vnpy/trader/gateway/ctpGateway/ctpGateway.py @@ -92,15 +92,14 @@ class CtpGateway(VtGateway): self.qryEnabled = False # 循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" - # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/femasGateway/femasGateway.py b/vnpy/trader/gateway/femasGateway/femasGateway.py index 497f146b..c5962a49 100644 --- a/vnpy/trader/gateway/femasGateway/femasGateway.py +++ b/vnpy/trader/gateway/femasGateway/femasGateway.py @@ -72,15 +72,15 @@ class FemasGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/huobiGateway/huobiGateway.py b/vnpy/trader/gateway/huobiGateway/huobiGateway.py index dd7b6224..cb36f3c2 100644 --- a/vnpy/trader/gateway/huobiGateway/huobiGateway.py +++ b/vnpy/trader/gateway/huobiGateway/huobiGateway.py @@ -60,15 +60,15 @@ class HuobiGateway(VtGateway): self.tradeApi = HuobiTradeApi(self) self.dataApi = HuobiDataApi(self) + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/ibGateway/ibGateway.py b/vnpy/trader/gateway/ibGateway/ibGateway.py index 51c12e5e..6104f002 100644 --- a/vnpy/trader/gateway/ibGateway/ibGateway.py +++ b/vnpy/trader/gateway/ibGateway/ibGateway.py @@ -138,16 +138,16 @@ class IbGateway(VtGateway): self.connected = False # 连接状态 self.api = IbWrapper(self) # API接口 + + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py b/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py index a23fa1cf..d7ebb69e 100644 --- a/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py +++ b/vnpy/trader/gateway/ksgoldGateway/ksgoldGateway.py @@ -46,15 +46,15 @@ class KsgoldGateway(VtGateway): self.orderInited = False # 委托初始化查询 self.tradeInited = False # 成交初始化查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py b/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py index fdfead52..c5b0a465 100644 --- a/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py +++ b/vnpy/trader/gateway/ksotpGateway/ksotpGateway.py @@ -68,15 +68,15 @@ class KsotpGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/lhangGateway/lhangGateway.py b/vnpy/trader/gateway/lhangGateway/lhangGateway.py index 3948482a..174906e6 100644 --- a/vnpy/trader/gateway/lhangGateway/lhangGateway.py +++ b/vnpy/trader/gateway/lhangGateway/lhangGateway.py @@ -47,15 +47,15 @@ class LhangGateway(VtGateway): self.api = LhangApi(self) + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/ltsGateway/ltsGateway.py b/vnpy/trader/gateway/ltsGateway/ltsGateway.py index 693e9542..83610ac2 100644 --- a/vnpy/trader/gateway/ltsGateway/ltsGateway.py +++ b/vnpy/trader/gateway/ltsGateway/ltsGateway.py @@ -68,16 +68,16 @@ class LtsGateway(VtGateway): self.qryConnected = False self.qryEnabled = False # 是否要启动循环查询 + + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json 文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/oandaGateway/oandaGateway.py b/vnpy/trader/gateway/oandaGateway/oandaGateway.py index e6cb9aff..642c81bf 100644 --- a/vnpy/trader/gateway/oandaGateway/oandaGateway.py +++ b/vnpy/trader/gateway/oandaGateway/oandaGateway.py @@ -54,15 +54,15 @@ class OandaGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/okcoinGateway/okcoinGateway.py b/vnpy/trader/gateway/okcoinGateway/okcoinGateway.py index 1b73dc3c..0fd23e7d 100644 --- a/vnpy/trader/gateway/okcoinGateway/okcoinGateway.py +++ b/vnpy/trader/gateway/okcoinGateway/okcoinGateway.py @@ -118,15 +118,15 @@ class OkcoinGateway(VtGateway): self.leverage = 0 self.connected = False + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/qdpGateway/qdpGateway.py b/vnpy/trader/gateway/qdpGateway/qdpGateway.py index d9443c75..1c621518 100644 --- a/vnpy/trader/gateway/qdpGateway/qdpGateway.py +++ b/vnpy/trader/gateway/qdpGateway/qdpGateway.py @@ -78,15 +78,14 @@ class QdpGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): - """连接""" - # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - + """连接""" try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/sgitGateway/sgitGateway.py b/vnpy/trader/gateway/sgitGateway/sgitGateway.py index ecee3026..d46501a3 100644 --- a/vnpy/trader/gateway/sgitGateway/sgitGateway.py +++ b/vnpy/trader/gateway/sgitGateway/sgitGateway.py @@ -89,15 +89,14 @@ class SgitGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" - # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/shzdGateway/shzdGateway.py b/vnpy/trader/gateway/shzdGateway/shzdGateway.py index ae192271..3ed9f305 100644 --- a/vnpy/trader/gateway/shzdGateway/shzdGateway.py +++ b/vnpy/trader/gateway/shzdGateway/shzdGateway.py @@ -69,15 +69,14 @@ class ShzdGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): """连接""" - # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py b/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py index 091d4693..dd46ffef 100644 --- a/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py +++ b/vnpy/trader/gateway/xspeedGateway/xspeedGateway.py @@ -78,15 +78,14 @@ class XspeedGateway(VtGateway): self.qryEnabled = False # 是否要启动循环查询 + self.fileName = self.gatewayName + '_connect.json' + self.filePath = getJsonPath(self.fileName, __file__) + #---------------------------------------------------------------------- def connect(self): - """连接""" - # 载入json文件 - fileName = self.gatewayName + '_connect.json' - filePath = getJsonPath(fileName, __file__) - + """连接""" try: - f = file(filePath) + f = file(self.filePath) except IOError: log = VtLogData() log.gatewayName = self.gatewayName diff --git a/vnpy/trader/ico/editor.ico b/vnpy/trader/ico/editor.ico new file mode 100644 index 0000000000000000000000000000000000000000..e52273768ba59b89403ae24282c21560ef00e4e0 GIT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rATrPn^00JIY8VTcKG5s3(;%(!CD}So zQ9bV?UF>-9*uoBz#uT>IeCy^({dzXMaPo1!$;vBvJo|*BeACW6S$RLq_sa(>eN9!C z`Yk#LG;VCepT24GBma5SfxeTDJkU2?$CsRXyz1FezSIAHm~Zkihlq!Rd?)MgCmwO2 zbmkD>StlInJLC8xe5e28FyEOc9AVp=vrm$pv2v9CjlXdX*K!Z{k_Ks=qI1&b8B2wZ0uaI43cuVJ>R?JV+EuF8ZczvTS zou6Ov`Uc^iSG>LctR8`S1nLrj^D90q?E1T+;{98+7oS$VzUh|Ew`AXf{~l~FgU^HP zZ$|KWu)Pkp=bN3M?=6tpgB9L$wHKdy&()q($gmo;3K>*`S0O`cuPS6n?OBBk=+yf_ n+a7uzsK-@!KxfW937*G!c>?x!&kddJpUa;ZICVv^t?~Z@K)c?_ literal 0 HcmV?d00001 diff --git a/vnpy/trader/language/chinese/text.py b/vnpy/trader/language/chinese/text.py index 4627da96..6029c21a 100644 --- a/vnpy/trader/language/chinese/text.py +++ b/vnpy/trader/language/chinese/text.py @@ -121,6 +121,9 @@ RESTORE = u'还原窗口' ABOUT = u'关于' TEST = u'测试' CONNECT = u'连接' +EDIT_SETTING = u'编辑配置' +LOAD = u'读取' +SAVE = u'保存' CPU_MEMORY_INFO = u'CPU使用率:{cpu}% 内存使用率:{memory}%' CONFIRM_EXIT = u'确认退出?' diff --git a/vnpy/trader/language/english/text.py b/vnpy/trader/language/english/text.py index bf2c14b3..17b307d6 100644 --- a/vnpy/trader/language/english/text.py +++ b/vnpy/trader/language/english/text.py @@ -121,6 +121,9 @@ RESTORE = u'Restore Window' ABOUT = u'About' TEST = u'Test' CONNECT = u'Connect ' +EDIT_SETTING = 'Edit Setting' +LOAD = 'Load' +SAVE = 'Save' CPU_MEMORY_INFO = u'CPU Usage:{cpu}% Memory Usage:{memory}%' CONFIRM_EXIT = u'Confirm Exit?' diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 0a793642..c88cadb9 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -7,11 +7,12 @@ import platform from collections import OrderedDict from vnpy.event import * -from vnpy.trader.vtEvent import * -from vnpy.trader.vtFunction import * -from vnpy.trader.vtGateway import * -from vnpy.trader import vtText -from vnpy.trader.uiQt import QtGui, QtWidgets, QtCore, BASIC_FONT +from .vtEvent import * +from .vtFunction import * +from .vtGateway import * +from . import vtText +from .uiQt import QtGui, QtWidgets, QtCore, BASIC_FONT +from .vtFunction import jsonPathDict COLOR_RED = QtGui.QColor('red') @@ -1229,3 +1230,90 @@ class ContractManager(QtWidgets.QWidget): self.monitor.refresh() + +######################################################################## +class SettingEditor(QtWidgets.QWidget): + """配置编辑器""" + + #---------------------------------------------------------------------- + def __init__(self, mainEngine, parent=None): + """Constructor""" + super(SettingEditor, self).__init__(parent) + + self.mainEngine = mainEngine + self.currentFileName = '' + + self.initUi() + + #---------------------------------------------------------------------- + def initUi(self): + """初始化界面""" + self.setWindowTitle(vtText.EDIT_SETTING) + + self.comboFileName = QtWidgets.QComboBox() + self.comboFileName.addItems(jsonPathDict.keys()) + + buttonLoad = QtWidgets.QPushButton(vtText.LOAD) + buttonSave = QtWidgets.QPushButton(vtText.SAVE) + buttonLoad.clicked.connect(self.loadSetting) + buttonSave.clicked.connect(self.saveSetting) + + self.editSetting = QtWidgets.QTextEdit() + self.labelPath = QtWidgets.QLabel() + + hbox = QtWidgets.QHBoxLayout() + hbox.addWidget(self.comboFileName) + hbox.addWidget(buttonLoad) + hbox.addWidget(buttonSave) + hbox.addStretch() + + vbox = QtWidgets.QVBoxLayout() + vbox.addLayout(hbox) + vbox.addWidget(self.editSetting) + vbox.addWidget(self.labelPath) + + self.setLayout(vbox) + + #---------------------------------------------------------------------- + def loadSetting(self): + """加载配置""" + self.currentFileName = str(self.comboFileName.currentText()) + filePath = jsonPathDict[self.currentFileName] + self.labelPath.setText(filePath) + + with open(filePath) as f: + self.editSetting.clear() + + for line in f: + line = line.replace('\n', '') # 移除换行符号 + line = line.decode('UTF-8') + self.editSetting.append(line) + + #---------------------------------------------------------------------- + def saveSetting(self): + """保存配置""" + if not self.currentFileName: + return + + filePath = jsonPathDict[self.currentFileName] + + with open(filePath, 'w') as f: + content = self.editSetting.toPlainText() + content = content.encode('UTF-8') + f.write(content) + + #---------------------------------------------------------------------- + def show(self): + """显示""" + self.comboFileName.clear() + self.comboFileName.addItems(jsonPathDict.keys()) + + super(SettingEditor, self).showMaximized() + + + + + + + + diff --git a/vnpy/trader/uiMainWindow.py b/vnpy/trader/uiMainWindow.py index 27c3f5e7..2fd2769f 100644 --- a/vnpy/trader/uiMainWindow.py +++ b/vnpy/trader/uiMainWindow.py @@ -117,6 +117,7 @@ class MainWindow(QtWidgets.QMainWindow): # 帮助 helpMenu = menubar.addMenu(vtText.HELP) helpMenu.addAction(self.createAction(vtText.CONTRACT_SEARCH, self.openContract, loadIconPath('contract.ico'))) + helpMenu.addAction(self.createAction(vtText.EDIT_SETTING, self.openSettingEditor, loadIconPath('editor.ico'))) helpMenu.addSeparator() helpMenu.addAction(self.createAction(vtText.RESTORE, self.restoreWindow, loadIconPath('restore.ico'))) helpMenu.addAction(self.createAction(vtText.ABOUT, self.openAbout, loadIconPath('about.ico'))) @@ -219,6 +220,15 @@ class MainWindow(QtWidgets.QMainWindow): except KeyError: self.widgetDict['contractM'] = ContractManager(self.mainEngine) self.widgetDict['contractM'].show() + + #---------------------------------------------------------------------- + def openSettingEditor(self): + """打开配置编辑""" + try: + self.widgetDict['settingEditor'].show() + except KeyError: + self.widgetDict['settingEditor'] = SettingEditor(self.mainEngine) + self.widgetDict['settingEditor'].show() #---------------------------------------------------------------------- def closeEvent(self, event): diff --git a/vnpy/trader/vtFunction.py b/vnpy/trader/vtFunction.py index 32bc99a4..acd7405c 100644 --- a/vnpy/trader/vtFunction.py +++ b/vnpy/trader/vtFunction.py @@ -63,7 +63,11 @@ def getTempPath(name): path = os.path.join(tempPath, name) return path - + + +# JSON配置文件路径 +jsonPathDict = {} + #---------------------------------------------------------------------- def getJsonPath(name, moduleFile): """ @@ -74,10 +78,14 @@ def getJsonPath(name, moduleFile): currentFolder = os.getcwd() currentJsonPath = os.path.join(currentFolder, name) if os.path.isfile(currentJsonPath): + jsonPathDict[name] = currentJsonPath return currentJsonPath moduleFolder = os.path.abspath(os.path.dirname(moduleFile)) moduleJsonPath = os.path.join(moduleFolder, '.', name) + jsonPathDict[name] = moduleJsonPath return moduleJsonPath + + diff --git a/vnpy/trader/vtGlobal.py b/vnpy/trader/vtGlobal.py index ab5a6f8d..0b4bc72c 100644 --- a/vnpy/trader/vtGlobal.py +++ b/vnpy/trader/vtGlobal.py @@ -7,14 +7,13 @@ import os import traceback import json - +from vtFunction import getJsonPath globalSetting = {} # 全局配置字典 settingFileName = "VT_setting.json" -path = os.path.abspath(os.path.dirname(__file__)) -settingFileName = os.path.join(path, settingFileName) +settingFilePath = getJsonPath(settingFileName, __file__) try: f = file(settingFileName)