From 676ce4a649b2a8be7745e873262d8932c832cb06 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 28 Jun 2017 17:40:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=8C=E6=83=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95UI=E7=9A=84=E7=95=8C=E9=9D=A2=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/dataRecorder/drEngine.py | 12 +++++ vnpy/trader/app/dataRecorder/uiDrWidget.py | 55 +++++++++------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/vnpy/trader/app/dataRecorder/drEngine.py b/vnpy/trader/app/dataRecorder/drEngine.py index 431c41c3..31f1b5a3 100644 --- a/vnpy/trader/app/dataRecorder/drEngine.py +++ b/vnpy/trader/app/dataRecorder/drEngine.py @@ -50,6 +50,9 @@ class DrEngine(object): # K线对象字典 self.barDict = {} + # 配置字典 + self.settingDict = OrderedDict() + # 负责执行数据库插入的单独线程相关 self.active = False # 工作状态 self.queue = Queue() # 队列 @@ -96,6 +99,7 @@ class DrEngine(object): # 设置需要记录的数据 if recordTick: + tick = VtTickData() self.tickDict[vtSymbol] = VtTickData() if recordBar: @@ -103,6 +107,14 @@ class DrEngine(object): if activeSymbol: self.activeSymbolDict[vtSymbol] = activeSymbol + + # 保存配置到缓存中 + self.settingDict[vtSymbol] = d + + #---------------------------------------------------------------------- + def getSetting(self): + """获取配置""" + return self.settingDict #---------------------------------------------------------------------- def procecssTickEvent(self, event): diff --git a/vnpy/trader/app/dataRecorder/uiDrWidget.py b/vnpy/trader/app/dataRecorder/uiDrWidget.py index 49833179..575702b3 100644 --- a/vnpy/trader/app/dataRecorder/uiDrWidget.py +++ b/vnpy/trader/app/dataRecorder/uiDrWidget.py @@ -4,14 +4,10 @@ 行情记录模块相关的GUI控制组件 ''' -import json - -from qtpy import QtWidgets, QtGui, QtCore - from vnpy.event import Event -from vnpy.trader.vtEvent import * - -from vnpy.trader.app.dataRecorder.language import text +from vnpy.trader.uiQt import QtWidgets, QtCore +from .drBase import EVENT_DATARECORDER_LOG +from .language import text ######################################################################## @@ -119,33 +115,24 @@ class DrEngineManager(QtWidgets.QWidget): #---------------------------------------------------------------------- def updateSetting(self): """显示引擎行情记录配置""" - with open(self.drEngine.settingFileName) as f: - drSetting = json.load(f) - - if 'tick' in drSetting: - l = drSetting['tick'] - - for setting in l: - self.tickTable.insertRow(0) - self.tickTable.setItem(0, 0, TableCell(setting[0])) - self.tickTable.setItem(0, 1, TableCell(setting[1])) - - if 'bar' in drSetting: - l = drSetting['bar'] - - for setting in l: - self.barTable.insertRow(0) - self.barTable.setItem(0, 0, TableCell(setting[0])) - self.barTable.setItem(0, 1, TableCell(setting[1])) - - if 'active' in drSetting: - d = drSetting['active'] - - for activeSymbol, symbol in d.items(): - self.activeTable.insertRow(0) - self.activeTable.setItem(0, 0, TableCell(activeSymbol)) - self.activeTable.setItem(0, 1, TableCell(symbol)) - + setting = self.drEngine.getSetting() + + for d in setting.values(): + if d['tick']: + self.tickTable.insertRow(0) + self.tickTable.setItem(0, 0, TableCell(d['symbol'])) + self.tickTable.setItem(0, 1, TableCell(d['gateway'])) + + if d['bar']: + self.barTable.insertRow(0) + self.barTable.setItem(0, 0, TableCell(d['symbol'])) + self.barTable.setItem(0, 1, TableCell(d['gateway'])) + + if d['active']: + self.activeTable.insertRow(0) + self.activeTable.setItem(0, 0, TableCell(d['active'])) + self.activeTable.setItem(0, 1, TableCell(d['symbol'])) + self.tickTable.resizeColumnsToContents() self.barTable.resizeColumnsToContents() self.activeTable.resizeColumnsToContents()