Merge remote-tracking branch 'vnpy/dev' into dev

This commit is contained in:
wisfern 2017-08-09 17:33:18 +08:00
commit dd6f0135bd
3 changed files with 41 additions and 5 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']))

View File

@ -329,7 +329,7 @@ class Api(OandaApi):
tick.vtSymbol = '.'.join([tick.symbol, tick.exchange]) tick.vtSymbol = '.'.join([tick.symbol, tick.exchange])
tick.bidPrice1 = d['bid'] tick.bidPrice1 = d['bid']
tick.askPrice1 = d['ask'] tick.askPrice1 = d['ask']
tick.time = getTime(d['time']) tick.time = getTime(d['time']) + '.0' # 补齐毫秒部分
# 做市商的TICK数据只有买卖的报价因此最新价格选用中间价代替 # 做市商的TICK数据只有买卖的报价因此最新价格选用中间价代替
tick.lastPrice = (tick.bidPrice1 + tick.askPrice1)/2 tick.lastPrice = (tick.bidPrice1 + tick.askPrice1)/2