diff --git a/vnpy/trader/app/dataRecorder/drEngine.py b/vnpy/trader/app/dataRecorder/drEngine.py index 6fa4f512..63877963 100644 --- a/vnpy/trader/app/dataRecorder/drEngine.py +++ b/vnpy/trader/app/dataRecorder/drEngine.py @@ -101,6 +101,18 @@ class DrEngine(object): tick = VtTickData() # 该tick实例可以用于缓存部分数据(目前未使用) self.tickDict[vtSymbol] = tick + + # 保存到配置字典中 + if vtSymbol not in self.settingDict: + d = { + 'symbol': symbol, + 'gateway': setting[1], + 'tick': True + } + self.settingDict[vtSymbol] = d + else: + d = self.settingDict[vtSymbol] + d['tick'] = True if 'bar' in drSetting: l = drSetting['bar'] @@ -124,6 +136,18 @@ class DrEngine(object): bar = VtBarData() self.barDict[vtSymbol] = bar + + # 保存到配置字典中 + if vtSymbol not in self.settingDict: + d = { + 'symbol': symbol, + 'gateway': setting[1], + 'bar': True + } + self.settingDict[vtSymbol] = d + else: + d = self.settingDict[vtSymbol] + d['bar'] = True if 'active' in drSetting: d = drSetting['active'] @@ -131,6 +155,18 @@ class DrEngine(object): # 注意这里的vtSymbol对于IB和LTS接口,应该后缀.交易所 for activeSymbol, vtSymbol in d.items(): self.activeSymbolDict[vtSymbol] = activeSymbol + + # 保存到配置字典中 + if vtSymbol not in self.settingDict: + d = { + 'symbol': symbol, + 'gateway': setting[1], + 'active': True + } + self.settingDict[vtSymbol] = d + else: + d = self.settingDict[vtSymbol] + d['active'] = True ##---------------------------------------------------------------------- #def loadCsvSetting(self): @@ -174,7 +210,7 @@ class DrEngine(object): #self.activeSymbolDict[vtSymbol] = activeSymbol ## 保存配置到缓存中 - self.settingDict[vtSymbol] = d + #self.settingDict[vtSymbol] = d #---------------------------------------------------------------------- def getSetting(self): diff --git a/vnpy/trader/app/dataRecorder/uiDrWidget.py b/vnpy/trader/app/dataRecorder/uiDrWidget.py index 575702b3..78a898fc 100644 --- a/vnpy/trader/app/dataRecorder/uiDrWidget.py +++ b/vnpy/trader/app/dataRecorder/uiDrWidget.py @@ -118,17 +118,17 @@ class DrEngineManager(QtWidgets.QWidget): setting = self.drEngine.getSetting() for d in setting.values(): - if d['tick']: + if 'tick' in d and 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']: + if 'bar' in d and 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']: + if 'active'in d and d['active']: self.activeTable.insertRow(0) self.activeTable.setItem(0, 0, TableCell(d['active'])) self.activeTable.setItem(0, 1, TableCell(d['symbol']))