修复DataRecorder的bug

This commit is contained in:
vn.py 2017-08-07 11:10:38 +08:00
parent 857668d27a
commit fe198aa40f
2 changed files with 40 additions and 4 deletions

View File

@ -102,6 +102,18 @@ class DrEngine(object):
tick = VtTickData() # 该tick实例可以用于缓存部分数据目前未使用 tick = VtTickData() # 该tick实例可以用于缓存部分数据目前未使用
self.tickDict[vtSymbol] = 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: if 'bar' in drSetting:
l = drSetting['bar'] l = drSetting['bar']
@ -125,6 +137,18 @@ class DrEngine(object):
bar = VtBarData() bar = VtBarData()
self.barDict[vtSymbol] = bar 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: if 'active' in drSetting:
d = drSetting['active'] d = drSetting['active']
@ -132,6 +156,18 @@ class DrEngine(object):
for activeSymbol, vtSymbol in d.items(): for activeSymbol, vtSymbol in d.items():
self.activeSymbolDict[vtSymbol] = activeSymbol 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): #def loadCsvSetting(self):
#"""加载CSV配置""" #"""加载CSV配置"""
@ -174,7 +210,7 @@ class DrEngine(object):
#self.activeSymbolDict[vtSymbol] = activeSymbol #self.activeSymbolDict[vtSymbol] = activeSymbol
## 保存配置到缓存中 ## 保存配置到缓存中
self.settingDict[vtSymbol] = d #self.settingDict[vtSymbol] = d
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getSetting(self): def getSetting(self):

View File

@ -118,17 +118,17 @@ class DrEngineManager(QtWidgets.QWidget):
setting = self.drEngine.getSetting() setting = self.drEngine.getSetting()
for d in setting.values(): for d in setting.values():
if d['tick']: if 'tick' in d and d['tick']:
self.tickTable.insertRow(0) self.tickTable.insertRow(0)
self.tickTable.setItem(0, 0, TableCell(d['symbol'])) self.tickTable.setItem(0, 0, TableCell(d['symbol']))
self.tickTable.setItem(0, 1, TableCell(d['gateway'])) self.tickTable.setItem(0, 1, TableCell(d['gateway']))
if d['bar']: if 'bar' in d and d['bar']:
self.barTable.insertRow(0) self.barTable.insertRow(0)
self.barTable.setItem(0, 0, TableCell(d['symbol'])) self.barTable.setItem(0, 0, TableCell(d['symbol']))
self.barTable.setItem(0, 1, TableCell(d['gateway'])) self.barTable.setItem(0, 1, TableCell(d['gateway']))
if d['active']: if 'active'in d and d['active']:
self.activeTable.insertRow(0) self.activeTable.insertRow(0)
self.activeTable.setItem(0, 0, TableCell(d['active'])) self.activeTable.setItem(0, 0, TableCell(d['active']))
self.activeTable.setItem(0, 1, TableCell(d['symbol'])) self.activeTable.setItem(0, 1, TableCell(d['symbol']))