增加收盘后保持所有委托清单至运行目录子目录Ordres下。
This commit is contained in:
parent
414e319529
commit
33dbc32042
@ -9,6 +9,7 @@ from PyQt4 import QtGui, QtCore
|
||||
from eventEngine import *
|
||||
from vtFunction import *
|
||||
from vtGateway import *
|
||||
import os
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -334,16 +335,21 @@ class BasicMonitor(QtGui.QTableWidget):
|
||||
self.sorting = sorting
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def saveToCsv(self):
|
||||
def saveToCsv(self, path=EMPTY_STRING):
|
||||
"""保存表格内容到CSV文件"""
|
||||
# 先隐藏右键菜单
|
||||
self.menu.close()
|
||||
|
||||
|
||||
# 获取想要保存的文件名
|
||||
path = QtGui.QFileDialog.getSaveFileName(self, '保存数据', '', 'CSV(*.csv)')
|
||||
if not path:
|
||||
# 先隐藏右键菜单
|
||||
self.menu.close()
|
||||
|
||||
path = QtGui.QFileDialog.getSaveFileName(self, '保存数据', '', 'CSV(*.csv)')
|
||||
|
||||
log = VtLogData()
|
||||
log.gatewayName = u'-'
|
||||
|
||||
try:
|
||||
if not path.isEmpty():
|
||||
if not os.path.exists(path):
|
||||
with open(unicode(path), 'wb') as f:
|
||||
writer = csv.writer(f)
|
||||
|
||||
@ -361,9 +367,16 @@ class BasicMonitor(QtGui.QTableWidget):
|
||||
unicode(item.text()).encode('gbk'))
|
||||
else:
|
||||
rowdata.append('')
|
||||
writer.writerow(rowdata)
|
||||
writer.writerow(rowdata)
|
||||
|
||||
log.logContent = u'数据保存至:{0}'.format(path)
|
||||
|
||||
except IOError:
|
||||
pass
|
||||
log.logContent = u'文件IO失败:{0}'.format(path)
|
||||
|
||||
event1 = Event(type_=EVENT_LOG)
|
||||
event1.dict_['data'] = log
|
||||
self.eventEngine.put(event1)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def initMenu(self):
|
||||
|
@ -7,6 +7,8 @@ from ctaAlgo.uiCtaWidget import CtaEngineManager
|
||||
from dataRecorder.uiDrWidget import DrEngineManager
|
||||
from riskManager.uiRmWidget import RmEngineManager
|
||||
|
||||
import os
|
||||
|
||||
########################################################################
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
"""主窗口"""
|
||||
@ -41,7 +43,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
widgetLogM, dockLogM = self.createDock(LogMonitor, u'日志', QtCore.Qt.BottomDockWidgetArea)
|
||||
widgetErrorM, dockErrorM = self.createDock(ErrorMonitor, u'错误', QtCore.Qt.BottomDockWidgetArea)
|
||||
widgetTradeM, dockTradeM = self.createDock(TradeMonitor, u'成交', QtCore.Qt.BottomDockWidgetArea)
|
||||
widgetOrderM, dockOrderM = self.createDock(OrderMonitor, u'委托', QtCore.Qt.RightDockWidgetArea)
|
||||
self.widgetOrderM, dockOrderM = self.createDock(OrderMonitor, u'委托', QtCore.Qt.RightDockWidgetArea)
|
||||
widgetPositionM, dockPositionM = self.createDock(PositionMonitor, u'持仓', QtCore.Qt.BottomDockWidgetArea)
|
||||
widgetAccountM, dockAccountM = self.createDock(AccountMonitor, u'资金', QtCore.Qt.BottomDockWidgetArea)
|
||||
widgetTradingW, dockTradingW = self.createDock(TradingWidget, u'交易', QtCore.Qt.LeftDockWidgetArea)
|
||||
@ -201,6 +203,14 @@ class MainWindow(QtGui.QMainWindow):
|
||||
if dt.minute == 40 and dt.second == 0 and self.connectGatewayName != EMPTY_STRING:
|
||||
self.mainEngine.writeLog(u'重新连接{0}'.format(self.connectGatewayName))
|
||||
self.mainEngine.connect(self.connectGatewayName)
|
||||
|
||||
# 收盘后保存所有委托记录
|
||||
if dt.hour == 15 and dt.minute == 1 and self.connectGatewayName != EMPTY_STRING:
|
||||
orderfile = os.getcwd() +'/orders/{0}.csv'.format(datetime.now().strftime('%y%m%d'))
|
||||
if os.path.exists(orderfile):
|
||||
return
|
||||
else:
|
||||
self.widgetOrderM.saveToCsv(path=orderfile)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
def getCpuMemory(self):
|
||||
|
Loading…
Reference in New Issue
Block a user