From 790097f8822ecb86aa83294a7d356c4eeadd1767 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Fri, 28 Oct 2016 15:22:31 +0800 Subject: [PATCH] =?UTF-8?q?bug=20fix=EF=BC=8C=E8=A7=A3=E5=86=B31=E5=88=86?= =?UTF-8?q?=E9=92=9F=E5=86=85=E9=87=8D=E5=A4=8D=E8=B0=83=E7=94=A8=E4=BF=9D?= =?UTF-8?q?=E5=AD=98bar=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/uiMainWindow.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vn.trader/uiMainWindow.py b/vn.trader/uiMainWindow.py index 54fa7a25..6048df47 100644 --- a/vn.trader/uiMainWindow.py +++ b/vn.trader/uiMainWindow.py @@ -27,9 +27,11 @@ class MainWindow(QtGui.QMainWindow): self.loadWindowSettings() self.connected = False - self.autoDisConnect = False + self.orderSaveDate = EMPTY_STRING + self.barSaveDate = EMPTY_STRING + self.connectGatewayDict = {} # ---------------------------------------------------------------------- def initUi(self): @@ -251,9 +253,11 @@ class MainWindow(QtGui.QMainWindow): # 交易日收盘后保存所有委托记录, dt = datetime.now() - if dt.hour == 15 and dt.minute == 1 and len(self.connectGatewayDict) > 0: + today = datetime.now().strftime('%y%m%d') + if dt.hour == 15 and dt.minute == 1 and len(self.connectGatewayDict) > 0 and today!=self.orderSaveDate: + self.orderSaveDate = today self.mainEngine.writeLog(u'保存所有委托记录') - orderfile = os.getcwd() +'/orders/{0}.csv'.format(datetime.now().strftime('%y%m%d')) + orderfile = os.getcwd() +'/orders/{0}.csv'.format(self.orderSaveDate) if os.path.exists(orderfile): return else: @@ -261,10 +265,15 @@ class MainWindow(QtGui.QMainWindow): # 调用各策略保存数据 if ((dt.hour == 15 and dt.minute == 1) or (dt.hour == 2 and dt.minute == 31)) \ - and len(self.connectGatewayDict) > 0: + and len(self.connectGatewayDict) > 0 \ + and today != self.barSaveDate: + self.barSaveDate = today self.mainEngine.writeLog(u'调用各策略保存数据') self.mainEngine.saveData() + if not (dt.hour == 15 or dt.hour == 2): + self.barSaveDate = EMPTY_STRING + # ---------------------------------------------------------------------- def getCpuMemory(self): """获取CPU和内存状态信息"""