From fe198aa40f0f5ca0a5abbb9add10ef00d777c75e Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 7 Aug 2017 11:10:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDataRecorder=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/dataRecorder/drEngine.py | 38 +++++++++++++++++++++- vnpy/trader/app/dataRecorder/uiDrWidget.py | 6 ++-- 2 files changed, 40 insertions(+), 4 deletions(-) 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'])) From ea3ca6427aa52c0567bddcb17392e2ffe50c9019 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 9 Aug 2017 12:41:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E9=BD=90OANDA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E8=A1=8C=E6=83=85=E6=97=B6=E9=97=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E6=AF=AB=E7=A7=92=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/oandaGateway/oandaGateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnpy/trader/gateway/oandaGateway/oandaGateway.py b/vnpy/trader/gateway/oandaGateway/oandaGateway.py index 642c81bf..94b2cccb 100644 --- a/vnpy/trader/gateway/oandaGateway/oandaGateway.py +++ b/vnpy/trader/gateway/oandaGateway/oandaGateway.py @@ -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