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

@ -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):

View File

@ -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']))

View File

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