增加了订阅合约编辑
This commit is contained in:
parent
3ad2fa5159
commit
615b4c69ba
58
vn.trader/dataRecorder/uiDrEdit.py
Normal file
58
vn.trader/dataRecorder/uiDrEdit.py
Normal file
@ -0,0 +1,58 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
'''
|
||||
行情记录模块相关的GUI控制组件
|
||||
'''
|
||||
from PyQt4.QtCore import QDir
|
||||
from PyQt4.QtGui import QFileSystemModel
|
||||
from PyQt4.QtGui import QTreeView
|
||||
|
||||
from uiBasicWidget import QtGui, QtCore
|
||||
from eventEngine import *
|
||||
|
||||
from eventType import EVENT_CONTRACT
|
||||
|
||||
|
||||
class DrEditWidget(QtGui.QWidget):
|
||||
"""行情数据记录引擎管理组件"""
|
||||
signal = QtCore.pyqtSignal(type(Event()))
|
||||
|
||||
def __init__(self, drEngine, eventEngine, parent=None):
|
||||
"""Constructor"""
|
||||
super(DrEditWidget, self).__init__(parent)
|
||||
|
||||
self.drEngine = drEngine
|
||||
self.eventEngine = eventEngine
|
||||
|
||||
# 保存合约详细信息的字典
|
||||
self.contractDict = {}
|
||||
|
||||
self.initUi()
|
||||
self.updateSetting()
|
||||
self.registerEvent()
|
||||
|
||||
def initUi(self):
|
||||
self.qTreeView = QTreeView()
|
||||
model = QFileSystemModel()
|
||||
model.setRootPath(QDir.currentPath())
|
||||
self.qTreeView.setModel(model)
|
||||
self.qTreeView.setRootIndex(model.index(QDir.currentPath()))
|
||||
|
||||
vbox = QtGui.QVBoxLayout()
|
||||
vbox.addWidget(self.qTreeView)
|
||||
self.setLayout(vbox)
|
||||
|
||||
def updateSetting(self):
|
||||
pass
|
||||
|
||||
def updateContract(self, event):
|
||||
"""更新合约数据"""
|
||||
contract = event.dict_['data']
|
||||
self.contractDict[contract.vtSymbol] = contract
|
||||
self.contractDict[contract.symbol] = contract # 使用常规代码(不包括交易所)可能导致重复
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
def registerEvent(self):
|
||||
"""注册事件监听"""
|
||||
self.signal.connect(self.updateContract)
|
||||
self.eventEngine.register(EVENT_CONTRACT, self.signal.emit)
|
@ -6,6 +6,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from dataRecorder.uiDrEdit import DrEditWidget
|
||||
from uiBasicWidget import QtGui, QtCore
|
||||
from eventEngine import *
|
||||
|
||||
@ -95,13 +96,18 @@ class DrEngineManager(QtGui.QWidget):
|
||||
grid.addWidget(activeLabel, 0, 2)
|
||||
grid.addWidget(self.tickTable, 1, 0)
|
||||
grid.addWidget(self.barTable, 1, 1)
|
||||
grid.addWidget(self.activeTable, 1, 2)
|
||||
|
||||
grid.addWidget(self.activeTable, 1, 2)
|
||||
|
||||
btn = QtGui.QPushButton(u'编辑', self)
|
||||
|
||||
vbox = QtGui.QVBoxLayout()
|
||||
vbox.addLayout(grid)
|
||||
vbox.addWidget(btn)
|
||||
vbox.addWidget(self.logMonitor)
|
||||
self.setLayout(vbox)
|
||||
|
||||
btn.clicked.connect(self.openDr)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateLog(self, event):
|
||||
"""更新日志"""
|
||||
@ -144,12 +150,9 @@ class DrEngineManager(QtGui.QWidget):
|
||||
self.activeTable.insertRow(0)
|
||||
self.activeTable.setItem(0, 0, TableCell(activeSymbol))
|
||||
self.activeTable.setItem(0, 1, TableCell(symbol))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
def openDr(self):
|
||||
"""打开行情数据记录组件"""
|
||||
self.mDrEditWidget = DrEditWidget(self.drEngine, self.eventEngine)
|
||||
self.mDrEditWidget.showMaximized()
|
||||
|
Loading…
Reference in New Issue
Block a user