bug fix,解决1分钟内重复调用保存bar数据的问题

This commit is contained in:
msincenselee 2016-10-28 15:22:31 +08:00
parent 35e8e51862
commit 790097f882

View File

@ -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和内存状态信息"""