def initUi(self): vbox = QtGui.QVBoxLayout() vline = QtGui.QHBoxLayout() vline.setSpacing(2) btnTickAll = QtGui.QPushButton(u"全部记录Tick", self) btnBarAll = QtGui.QPushButton(u'全部记录Bar', self) btnSaveAll = QtGui.QPushButton(u'保存设置(重启后生效)', self) btnTickAll.clicked.connect(self.selectAllTick) btnBarAll.clicked.connect(self.selectAllBar) btnSaveAll.clicked.connect(self.saveSetting) vline.addWidget(btnTickAll) vline.addWidget(btnBarAll) vline.addWidget(btnSaveAll) vbox.addLayout(vline) self.qTreeView = QTreeView() self.model = TreeModel() self.qTreeView.setModel(self.model) self.qTreeView.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.qTreeView.setItemDelegateForColumn(1, CheckBoxDelegate(self)) self.qTreeView.setItemDelegateForColumn(2, CheckBoxDelegate(self)) self.qTreeView.setItemDelegateForColumn(3, CheckBoxDelegate(self)) self.qTreeView.setItemDelegateForColumn(5, ComboDelegate(self, ["CTP", "LTS", "XTP", "FEMAS", "XSPEED", "QDP", "KSOTP", "KSGOLD", "SGIT"])) vbox.addWidget(self.qTreeView) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(CTA_STRATEGY) # 按钮 startAllButton = QtGui.QPushButton(START_ALL) stopAllButton = QtGui.QPushButton(STOP_ALL) savePositionButton = QtGui.QPushButton(SAVE_POSITION_DATA) startAllButton.clicked.connect(self.startAll) stopAllButton.clicked.connect(self.stopAll) # savePositionButton.clicked.connect(self.ctaEngine.savePosition) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # CTA组件的日志监控 self.ctaLogMonitor = QtGui.QTextEdit() self.ctaLogMonitor.setReadOnly(True) self.ctaLogMonitor.setMaximumHeight(200) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(startAllButton) hbox2.addWidget(stopAllButton) # hbox2.addWidget(savePositionButton) hbox2.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.addWidget(self.ctaLogMonitor) self.setLayout(vbox)
def initStrategyManager(self): """初始化策略管理组件界面""" w = QtGui.QWidget() vbox = QtGui.QVBoxLayout() for name in self.ctaEngine.strategyDict.keys(): p = self.ctaEngine.strategyDict[name] if p.className == 'tradeTest': strategyManager = CtaStrategyManager(self.ctaEngine, self.eventEngine, name, p.className, '', '', p.longsymbol, p.shortsymbol) elif p.className == 'CtpAndIB': strategyManager = CtaStrategyManager(self.ctaEngine, self.eventEngine, name, p.className, '', '', p.longsymbol, p.shortsymbol) else: strategyManager = CtaStrategyManager(self.ctaEngine, self.eventEngine, name, p.className, p.direction, p.vtSymbol, '', '') vbox.addWidget(strategyManager) vbox.addStretch() w.setLayout(vbox) self.scrollArea.setWidget(w)
def initUi(self): """初始化界面""" self.setTitle(self.name) paramLabel = QtGui.QLabel(u'参数') varLabel = QtGui.QLabel(u'变量') self.paramMonitor = ValueMonitor(self) self.varMonitor = ValueMonitor(self) buttonStart = QtGui.QPushButton(u'启动') buttonStop = QtGui.QPushButton(u'停止') buttonStart.clicked.connect(self.start) buttonStop.clicked.connect(self.stop) hbox = QtGui.QHBoxLayout() hbox.addWidget(buttonStart) hbox.addWidget(buttonStop) hbox.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox) vbox.addWidget(paramLabel) vbox.addWidget(self.paramMonitor) vbox.addWidget(varLabel) vbox.addWidget(self.varMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'CTA策略') # 按钮 loadButton = QtGui.QPushButton(u'加载策略') startAllButton = QtGui.QPushButton(u'全部启动') stopAllButton = QtGui.QPushButton(u'全部停止') loadButton.clicked.connect(self.load) startAllButton.clicked.connect(self.startAll) stopAllButton.clicked.connect(self.stopAll) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() # CTA组件的日志监控 self.ctaLogMonitor = QtGui.QTextEdit() self.ctaLogMonitor.setReadOnly(True) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(loadButton) hbox2.addWidget(startAllButton) hbox2.addWidget(stopAllButton) hbox2.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.addWidget(self.ctaLogMonitor) self.setLayout(vbox)
def initUI(self): vbox1 = QtGui.QVBoxLayout() for x in self.l: fileName = "parameter_" + x['name'] + '.json' d = {} with open(fileName, 'r') as f: d = json.load(f) f.close() symbols = d['postoday'].keys() label = [u'策略名\持仓'] + symbols newTable = QtGui.QTableWidget(1, 3) newTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) newTable.setMaximumHeight(60) newTable.setHorizontalHeaderLabels(label) vbox1.addWidget(newTable) newItem = QtGui.QTableWidgetItem(x['name']) newTable.setItem(0, 0, newItem) newItem = QtGui.QTableWidgetItem(str(d['postoday'][symbols[0]])) newTable.setItem(0, 1, newItem) newItem = QtGui.QTableWidgetItem(' ') newTable.setItem(0, 2, newItem) if len(symbols) == 2: newItem = QtGui.QTableWidgetItem(str( d['postoday'][symbols[1]])) newTable.setItem(0, 2, newItem) self.vbox = vbox1 self.setLayout(self.vbox)
def initUi(self, startDate=None): """初始化界面""" self.setWindowTitle(u'Price') self.vbl_1 = QtGui.QVBoxLayout() self.initplotTick() # plotTick初始化 self.vbl_2 = QtGui.QVBoxLayout() self.initplotKline() # plotKline初始化 self.initplotTendency() # plot分时图的初始化 # 整体布局 self.hbl = QtGui.QHBoxLayout() self.hbl.addLayout(self.vbl_1) self.hbl.addLayout(self.vbl_2) self.setLayout(self.hbl) self.initHistoricalData() # 下载历史数据
def initUi(self): """初始化界面""" self.setWindowTitle(text.DATA_RECORDER) # 记录合约配置监控 tickLabel = QtGui.QLabel(text.TICK_RECORD) self.tickTable = QtGui.QTableWidget() self.tickTable.setColumnCount(2) self.tickTable.verticalHeader().setVisible(False) self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.tickTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.tickTable.setAlternatingRowColors(True) self.tickTable.setHorizontalHeaderLabels( [text.CONTRACT_SYMBOL, text.GATEWAY]) barLabel = QtGui.QLabel(text.BAR_RECORD) self.barTable = QtGui.QTableWidget() self.barTable.setColumnCount(2) self.barTable.verticalHeader().setVisible(False) self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.barTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.barTable.setAlternatingRowColors(True) self.barTable.setHorizontalHeaderLabels( [text.CONTRACT_SYMBOL, text.GATEWAY]) activeLabel = QtGui.QLabel(text.DOMINANT_CONTRACT) self.activeTable = QtGui.QTableWidget() self.activeTable.setColumnCount(2) self.activeTable.verticalHeader().setVisible(False) self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.activeTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.activeTable.setAlternatingRowColors(True) self.activeTable.setHorizontalHeaderLabels( [text.DOMINANT_SYMBOL, text.CONTRACT_SYMBOL]) # 日志监控 self.logMonitor = QtGui.QTextEdit() self.logMonitor.setReadOnly(True) self.logMonitor.setMinimumHeight(600) # 设置布局 grid = QtGui.QGridLayout() grid.addWidget(tickLabel, 0, 0) grid.addWidget(barLabel, 0, 1) grid.addWidget(activeLabel, 0, 2) grid.addWidget(self.tickTable, 1, 0) grid.addWidget(self.barTable, 1, 1) grid.addWidget(self.activeTable, 1, 2) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vbox.addWidget(self.logMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'行情数据记录工具') # 记录合约配置监控 tickLabel = QtGui.QLabel(u'Tick记录') self.tickTable = QtGui.QTableWidget() self.tickTable.setColumnCount(2) self.tickTable.verticalHeader().setVisible(False) self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.tickTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.tickTable.setAlternatingRowColors(True) self.tickTable.setHorizontalHeaderLabels([u'合约代码', u'接口']) barLabel = QtGui.QLabel(u'Bar记录') self.barTable = QtGui.QTableWidget() self.barTable.setColumnCount(2) self.barTable.verticalHeader().setVisible(False) self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.barTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.barTable.setAlternatingRowColors(True) self.barTable.setHorizontalHeaderLabels([u'合约代码', u'接口']) activeLabel = QtGui.QLabel(u'主力合约') self.activeTable = QtGui.QTableWidget() self.activeTable.setColumnCount(2) self.activeTable.verticalHeader().setVisible(False) self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.activeTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.activeTable.setAlternatingRowColors(True) self.activeTable.setHorizontalHeaderLabels([u'主力代码', u'合约代码']) # 日志监控 self.logMonitor = QtGui.QTextEdit() self.logMonitor.setReadOnly(True) self.logMonitor.setMinimumHeight(300) # 设置布局 grid = QtGui.QGridLayout() grid.addWidget(tickLabel, 0, 0) grid.addWidget(barLabel, 0, 1) grid.addWidget(activeLabel, 0, 2) grid.addWidget(self.tickTable, 1, 0) grid.addWidget(self.barTable, 1, 1) grid.addWidget(self.activeTable, 1, 2) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vbox.addWidget(self.logMonitor) self.setLayout(vbox)
def initStrategyManager(self): """初始化策略管理组件界面""" w = QtGui.QWidget() vbox = QtGui.QVBoxLayout() for name in self.ctaEngine.strategyDict.keys(): strategyManager = CtaStrategyManager(self.ctaEngine, self.eventEngine, name) vbox.addWidget(strategyManager) vbox.addStretch() w.setLayout(vbox) self.scrollArea.setWidget(w)
def __init__(self, l, parent=None): QtGui.QMainWindow.__init__(self, parent) console = MyConsole(self, l) console.setMinimumSize(350, 700) scroll = QtGui.QScrollArea() scroll.setWidget(console) scroll.setAutoFillBackground(True) scroll.setWidgetResizable(True) vbox = QtGui.QVBoxLayout() vbox.addWidget(scroll) self.setLayout(vbox) self.initUI()
def initUi(self): """初始化界面""" self.setTitle(self.name) self.paramMonitor = CtaValueMonitor(self) self.varMonitor = CtaValueMonitor(self) maxHeight = 60 self.paramMonitor.setMaximumHeight(maxHeight) self.varMonitor.setMaximumHeight(maxHeight) buttonInit = QtGui.QPushButton(u'初始化') buttonStart = QtGui.QPushButton(u'启动') buttonStop = QtGui.QPushButton(u'停止') buttonParam = QtGui.QPushButton(u'参数') buttonDelete = QtGui.QPushButton(u'删除') buttonDelete.clicked.connect(self.delete) #updateInfo = QtGui.QPushButton(u'更新缓存') #buttonPosition = QtGui.QPushButton(u'重置今持仓') buttonInit.clicked.connect(self.init) buttonStart.clicked.connect(self.start) buttonStop.clicked.connect(self.stop) buttonParam.clicked.connect(self.param) #updateInfo.clicked.connect(self.update) #buttonPosition.clicked.connect(self.position) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(buttonInit) hbox1.addWidget(buttonStart) hbox1.addWidget(buttonStop) hbox1.addWidget(buttonParam) hbox1.addWidget(buttonDelete) #hbox1.addWidget(updateInfo) #hbox1.addWidget(buttonPosition) hbox1.addStretch() hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(self.paramMonitor) hbox3 = QtGui.QHBoxLayout() hbox3.addWidget(self.varMonitor) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'登录') # 设置界面 self.userName = QtGui.QLineEdit() self.password = QtGui.QTextEdit() self.comboStrategy = QtGui.QComboBox() grid = QtGui.QGridLayout() grid.addWidget(LoginLine(), 1, 0, 1, 2) grid.addWidget(QtGui.QLabel(u'用户名'), 2, 0) grid.addWidget(self.userName, 2, 1) grid.addWidget(QtGui.QLabel(u'令牌'), 3, 0) grid.addWidget(self.password, 3, 1) grid.addWidget(LoginLine(), 4, 0, 1, 2) grid.addWidget(QtGui.QLabel(u'策略'), 5, 0) grid.addWidget(self.comboStrategy, 5, 1) grid.addWidget(LoginLine(), 6, 0, 1, 2) self.buttonCancel = QtGui.QPushButton(u'取消') self.buttonConfirm = QtGui.QPushButton(u'确认') hbox = QtGui.QHBoxLayout() hbox.addWidget(self.buttonConfirm) hbox.addWidget(self.buttonCancel) self.buttonConfirm.setDefault(True) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox) # 设为固定大小 self.setFixedSize(self.sizeHint()) self.buttonCancel.clicked.connect(self.close) self.buttonConfirm.clicked.connect(self.login) self.userName.returnPressed.connect(self.password.setFocus) # init username & token username = self.setting['username'] token = self.setting['token'] self.userName.setText(username) self.password.setText(token)
def initUi(self): """初始化界面""" self.setTitle(self.name) self.paramMonitor = CtaValueMonitor(self) self.varMonitor = CtaValueMonitor(self) hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(self.paramMonitor) hbox3 = QtGui.QHBoxLayout() hbox3.addWidget(self.varMonitor) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addLayout(hbox3) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'CTA策略') # 按钮 newButton = QtGui.QPushButton(u'新建策略') loadButton = QtGui.QPushButton(u'加载策略') initAllButton = QtGui.QPushButton(u'全部初始化') startAllButton = QtGui.QPushButton(u'全部启动') stopAllButton = QtGui.QPushButton(u'全部停止') savePositionButton = QtGui.QPushButton(u'保存持仓') newButton.clicked.connect(self.new) loadButton.clicked.connect(self.load) initAllButton.clicked.connect(self.initAll) startAllButton.clicked.connect(self.startAll) stopAllButton.clicked.connect(self.stopAll) savePositionButton.clicked.connect(self.ctaEngine.savePosition) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # CTA组件的日志监控 self.ctaLogMonitor = QtGui.QTextEdit() self.ctaLogMonitor.setReadOnly(True) self.ctaLogMonitor.setMaximumHeight(200) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(newButton) hbox2.addWidget(loadButton) hbox2.addWidget(initAllButton) hbox2.addWidget(startAllButton) hbox2.addWidget(stopAllButton) hbox2.addWidget(savePositionButton) hbox2.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.addWidget(self.ctaLogMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'CTA策略') # 按钮 loadButton = QtGui.QPushButton(u'加载策略') initAllButton = QtGui.QPushButton(u'全部初始化') startAllButton = QtGui.QPushButton(u'全部启动') stopAllButton = QtGui.QPushButton(u'全部停止') addStrategy = QtGui.QPushButton(u'添加策略') thumbnail = QtGui.QPushButton(u'策略持仓') loadButton.clicked.connect(self.load) initAllButton.clicked.connect(self.initAll) startAllButton.clicked.connect(self.startAll) stopAllButton.clicked.connect(self.stopAll) addStrategy.clicked.connect(self.addStrategy) thumbnail.clicked.connect(self.thumbnail) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # CTA组件的日志监控 self.ctaLogMonitor = QtGui.QTextEdit() self.ctaLogMonitor.setReadOnly(True) self.ctaLogMonitor.setMaximumHeight(200) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(loadButton) hbox2.addWidget(initAllButton) hbox2.addWidget(startAllButton) hbox2.addWidget(stopAllButton) hbox2.addWidget(addStrategy) hbox2.addWidget(thumbnail) hbox2.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.addWidget(self.ctaLogMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'任务管理') buttonStopAll = QtGui.QPushButton(u'全部停止') buttonStopAll.setObjectName(_fromUtf8('redButton')) buttonStopAll.clicked.connect(self.taskTab.stopAll) buttonClearAll = QtGui.QPushButton(u'清空所有') buttonClearAll.setObjectName(_fromUtf8('blueButton')) buttonClearAll.clicked.connect(self.taskTab.clearAll) hbox11 = QtGui.QHBoxLayout() hbox11.addWidget(buttonStopAll) hbox11.addWidget(buttonClearAll) hbox11.addStretch() grid = QtGui.QVBoxLayout() grid.addLayout(hbox11) grid.addWidget(self.taskTab) self.setLayout(grid)
def initUi(self): """初始化界面""" self.setTitle(self.name) self.paramMonitor = CtaValueMonitor(self) self.varMonitor = CtaValueMonitor(self) self.dynamicMonitor = CtaValueMonitor(self) maxHeight = 60 self.paramMonitor.setMaximumHeight(maxHeight) self.varMonitor.setMaximumHeight(maxHeight) buttonInit = QtGui.QPushButton(u'初始化') buttonStart = QtGui.QPushButton(u'启动') buttonStop = QtGui.QPushButton(u'停止') buttonInit.clicked.connect(self.init) buttonStart.clicked.connect(self.start) buttonStop.clicked.connect(self.stop) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(buttonInit) hbox1.addWidget(buttonStart) hbox1.addWidget(buttonStop) hbox1.addStretch() hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(self.paramMonitor) hbox3 = QtGui.QHBoxLayout() hbox3.addWidget(self.varMonitor) hbox4 = QtGui.QHBoxLayout() hbox4.addWidget(self.dynamicMonitor) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) vbox.addLayout(hbox4) self.setLayout(vbox)
def initStrategyManager(self): """初始化策略管理组件界面""" w = QtGui.QWidget() vbox = QtGui.QVBoxLayout() self.runID = 9999 for name in self.stockBacktestEngine.strategyDict.keys(): strategyManager = StockStrategyManager(self.stockBacktestEngine, self.eventEngine, name, self.runID) vbox.addWidget(strategyManager) self.runID -= 1 self.signal2.connect(self.updateBktResult) self.eventEngine.register(EVENT_BKT_STRATEGY + name, self.signal2.emit) vbox.addStretch() w.setLayout(vbox) self.scrollArea.setWidget(w)
def initUi(self): """初始化界面""" path = os.getcwd().rsplit('\\')[-1] self.setWindowTitle(u'{0} CTA策略'.format(path)) # 按钮 loadButton = QtGui.QPushButton(u'加载策略') initAllButton = QtGui.QPushButton(u'全部初始化') startAllButton = QtGui.QPushButton(u'全部启动') stopAllButton = QtGui.QPushButton(u'全部停止') loadButton.clicked.connect(self.load) initAllButton.clicked.connect(self.initAll) startAllButton.clicked.connect(self.startAll) stopAllButton.clicked.connect(self.stopAll) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # CTA组件的日志监控 self.ctaLogMonitor = QtGui.QTextEdit() self.ctaLogMonitor.setReadOnly(True) self.ctaLogMonitor.setMaximumHeight(200) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(loadButton) hbox2.addWidget(initAllButton) hbox2.addWidget(startAllButton) hbox2.addWidget(stopAllButton) hbox2.addStretch() vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.addWidget(self.ctaLogMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setTitle(self.name) self.baseMonitor = StockValueMonitor(self.stockBacktestEngine, self.eventEngine, self.name) self.extraMonitor = StockValueMonitor(self.stockBacktestEngine, self.eventEngine, self.name) height = 60 self.baseMonitor.setFixedHeight(height) self.extraMonitor.setFixedHeight(height) buttonEdit = QtGui.QPushButton(u'编辑策略') buttonStart = QtGui.QPushButton(u'启动回测') buttonShow = QtGui.QPushButton(u'绩效报告') buttonEdit.clicked.connect(self.edit) buttonStart.clicked.connect(self.start) buttonShow.clicked.connect(self.show) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(buttonEdit) hbox1.addWidget(buttonStart) hbox1.addWidget(buttonShow) hbox1.addStretch() hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(self.baseMonitor) hbox3 = QtGui.QHBoxLayout() hbox3.addWidget(self.extraMonitor) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setTitle(self.name) self.paramMonitor = CtaValueMonitor(self) self.varMonitor = CtaValueMonitor(self) height = 85 self.paramMonitor.setFixedHeight(height) self.varMonitor.setFixedHeight(height) buttonInit = QtGui.QPushButton(text.INIT) buttonStart = QtGui.QPushButton(text.START) buttonStop = QtGui.QPushButton(text.STOP) buttonInit.clicked.connect(self.init) buttonStart.clicked.connect(self.start) buttonStop.clicked.connect(self.stop) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(buttonInit) hbox1.addWidget(buttonStart) hbox1.addWidget(buttonStop) hbox1.addStretch() hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(self.paramMonitor) hbox3 = QtGui.QHBoxLayout() hbox3.addWidget(self.varMonitor) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addLayout(hbox3) self.setLayout(vbox)
def initUi(self): """""" QtGui.QWidget.__init__(self) # 调用父类初始化方法 self.setWindowTitle(u'设置参数') self.resize(300,400) # 设置窗口大小 gridlayout = QtGui.QGridLayout() # 创建布局组件 i = 0 lName = QtGui.QLabel(u'参数') lValue = QtGui.QLabel(u'数值') gridlayout.addWidget(lName, i, 0 ) gridlayout.addWidget(lValue, i, 1 ) for name in self.paramDict: i += 1 label = QtGui.QLabel(name) # 创建单选框 self.valueEdit[name] = QtGui.QLineEdit() self.valueEdit[name].setText(str(self.paramDict[name])) self.valueEdit[name].setFocusPolicy(QtCore.Qt.NoFocus) gridlayout.addWidget(label, i, 0 ) # 添加文本 gridlayout.addWidget(self.valueEdit[name], i, 1) # 添加文本框 vbox = QtGui.QVBoxLayout() vbox.addLayout(gridlayout) self.addButton(vbox) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'风险管理') # 设置界面 self.buttonSwitchEngineStatus = QtGui.QPushButton(u'风控模块未启动') self.spinOrderFlowLimit = RmSpinBox(self.rmEngine.orderFlowLimit) self.spinOrderFlowClear = RmSpinBox(self.rmEngine.orderFlowClear) self.spinOrderSizeLimit = RmSpinBox(self.rmEngine.orderSizeLimit) self.spinTradeLimit = RmSpinBox(self.rmEngine.tradeLimit) self.spinWorkingOrderLimit = RmSpinBox(self.rmEngine.workingOrderLimit) self.spinOrderCancelLimit = RmSpinBox(self.rmEngine.orderCancelLimit) buttonClearOrderFlowCount = QtGui.QPushButton(u'清空流控计数') buttonClearTradeCount = QtGui.QPushButton(u'清空总成交计数') buttonSaveSetting = QtGui.QPushButton(u'保存设置') Label = QtGui.QLabel grid = QtGui.QGridLayout() grid.addWidget(Label(u'工作状态'), 0, 0) grid.addWidget(self.buttonSwitchEngineStatus, 0, 1) grid.addWidget(RmLine(), 1, 0, 1, 2) grid.addWidget(Label(u'流控上限'), 2, 0) grid.addWidget(self.spinOrderFlowLimit, 2, 1) grid.addWidget(Label(u'流控清空(秒)'), 3, 0) grid.addWidget(self.spinOrderFlowClear, 3, 1) grid.addWidget(RmLine(), 4, 0, 1, 2) grid.addWidget(Label(u'单笔委托上限'), 5, 0) grid.addWidget(self.spinOrderSizeLimit, 5, 1) grid.addWidget(RmLine(), 6, 0, 1, 2) grid.addWidget(Label(u'总成交上限'), 7, 0) grid.addWidget(self.spinTradeLimit, 7, 1) grid.addWidget(RmLine(), 8, 0, 1, 2) grid.addWidget(Label(u'活动订单上限'), 9, 0) grid.addWidget(self.spinWorkingOrderLimit, 9, 1) grid.addWidget(RmLine(), 10, 0, 1, 2) grid.addWidget(Label(u'单合约撤单上限'), 11, 0) grid.addWidget(self.spinOrderCancelLimit, 11, 1) hbox = QtGui.QHBoxLayout() hbox.addWidget(buttonClearOrderFlowCount) hbox.addWidget(buttonClearTradeCount) hbox.addStretch() hbox.addWidget(buttonSaveSetting) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox) # 连接组件信号 self.spinOrderFlowLimit.valueChanged.connect( self.rmEngine.setOrderFlowLimit) self.spinOrderFlowClear.valueChanged.connect( self.rmEngine.setOrderFlowClear) self.spinOrderSizeLimit.valueChanged.connect( self.rmEngine.setOrderSizeLimit) self.spinTradeLimit.valueChanged.connect(self.rmEngine.setTradeLimit) self.spinWorkingOrderLimit.valueChanged.connect( self.rmEngine.setWorkingOrderLimit) self.spinOrderCancelLimit.valueChanged.connect( self.rmEngine.setOrderCancelLimit) self.buttonSwitchEngineStatus.clicked.connect(self.switchEngineSatus) buttonClearOrderFlowCount.clicked.connect( self.rmEngine.clearOrderFlowCount) buttonClearTradeCount.clicked.connect(self.rmEngine.clearTradeCount) buttonSaveSetting.clicked.connect(self.rmEngine.saveSetting) # 设为固定大小 self.setFixedSize(self.sizeHint())
def initUi(self): """初始化界面""" self.setWindowTitle(text.DATA_RECORDER) # 记录合约配置监控 tickLabel = QtGui.QLabel(text.TICK_RECORD) self.tickTable = QtGui.QTableWidget() self.tickTable.setColumnCount(2) self.tickTable.verticalHeader().setVisible(False) self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.tickTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.tickTable.setAlternatingRowColors(True) self.tickTable.setHorizontalHeaderLabels( [text.CONTRACT_SYMBOL, text.GATEWAY]) barLabel = QtGui.QLabel(text.BAR_RECORD) self.barTable = QtGui.QTableWidget() self.barTable.setColumnCount(2) self.barTable.verticalHeader().setVisible(False) self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.barTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.barTable.setAlternatingRowColors(True) self.barTable.setHorizontalHeaderLabels( [text.CONTRACT_SYMBOL, text.GATEWAY]) activeLabel = QtGui.QLabel(text.DOMINANT_CONTRACT) self.activeTable = QtGui.QTableWidget() self.activeTable.setColumnCount(2) self.activeTable.verticalHeader().setVisible(False) self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.activeTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.activeTable.setAlternatingRowColors(True) self.activeTable.setHorizontalHeaderLabels( [text.DOMINANT_SYMBOL, text.CONTRACT_SYMBOL]) # 日志监控 self.logMonitor = QtGui.QTextEdit() self.logMonitor.setReadOnly(True) self.logMonitor.setMinimumHeight(600) # 设置布局 grid = QtGui.QGridLayout() grid.addWidget(tickLabel, 0, 0) grid.addWidget(barLabel, 0, 1) grid.addWidget(activeLabel, 0, 2) grid.addWidget(self.tickTable, 1, 0) grid.addWidget(self.barTable, 1, 1) grid.addWidget(self.activeTable, 1, 2) # 原有的布局结构 -> 备份 # vbox = QtGui.QVBoxLayout() # vbox.addLayout(grid) # vbox.addWidget(self.logMonitor) # self.setLayout(vbox) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) # 在底部增加的一个可切换组件,有价格图和行情两个界面 bottomWidget = QtGui.QTabWidget() priceWidget = PriceWidget(self.eventEngine, self.drEngine) bottomWidget.addTab(priceWidget, u'Price') bottomWidget.addTab(self.logMonitor, u'行情') vbox.addWidget(bottomWidget) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'股票策略回测') # 按钮 newButton = QtGui.QPushButton(u'新建策略') loadButton = QtGui.QPushButton(u'加载策略') newButton.clicked.connect(self.new) loadButton.clicked.connect(self.load) # 滚动区域,放置所有的CtaStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # 回测结果区域,Tab显示各项报告 self.tabWidget = QtGui.QTabWidget(self) self.model = QtGui.QStandardItemModel(self) self.summaryView = QtGui.QTableView(self) self.summaryView.setModel(self.model) self.summaryView.horizontalHeader().setStretchLastSection(True) self.summaryView.setEditTriggers(self.summaryView.NoEditTriggers) self.summaryView.setMaximumHeight(400) self.summaryView.resizeColumnsToContents() self.model2 = QtGui.QStandardItemModel(self) self.total_portfoliosView = QtGui.QTableView(self) self.total_portfoliosView.setModel(self.model2) self.total_portfoliosView.horizontalHeader().setStretchLastSection( True) self.total_portfoliosView.setEditTriggers( self.total_portfoliosView.NoEditTriggers) self.total_portfoliosView.setMaximumHeight(400) self.total_portfoliosView.resizeColumnsToContents() self.model3 = QtGui.QStandardItemModel(self) self.future_portfoliosView = QtGui.QTableView(self) self.future_portfoliosView.setModel(self.model3) self.future_portfoliosView.horizontalHeader().setStretchLastSection( True) self.future_portfoliosView.setEditTriggers( self.future_portfoliosView.NoEditTriggers) self.future_portfoliosView.setMaximumHeight(400) self.future_portfoliosView.resizeColumnsToContents() self.model4 = QtGui.QStandardItemModel(self) self.future_positionsView = QtGui.QTableView(self) self.future_positionsView.setModel(self.model4) self.future_positionsView.horizontalHeader().setStretchLastSection( True) self.future_positionsView.setEditTriggers( self.future_positionsView.NoEditTriggers) self.future_positionsView.setMaximumHeight(400) self.future_positionsView.resizeColumnsToContents() self.model5 = QtGui.QStandardItemModel(self) self.tradesView = QtGui.QTableView(self) self.tradesView.setModel(self.model5) self.tradesView.horizontalHeader().setStretchLastSection(True) self.tradesView.horizontalHeader().setVisible(False) self.tradesView.setEditTriggers(self.tradesView.NoEditTriggers) self.tradesView.setMaximumHeight(400) self.tradesView.resizeColumnsToContents() self.tabWidget.addTab(self.summaryView, "summary") self.tabWidget.addTab(self.total_portfoliosView, "total_portfolios") self.tabWidget.addTab(self.future_portfoliosView, "stock_portfolios") self.tabWidget.addTab(self.future_positionsView, "stock_positions") self.tabWidget.addTab(self.tradesView, "trades") # 回测图表 Button1 = QtGui.QPushButton(u'交易资料') Button2 = QtGui.QPushButton(u'周期分析') Button3 = QtGui.QPushButton(u'策略分析') Button4 = QtGui.QPushButton(u'交易分析') # Button1.clicked.connect(self.show1) # Button2.clicked.connect(self.show2) # Button3.clicked.connect(self.show3) # Button4.clicked.connect(self.show4) # 回测组件的日志监控 self.bktLogMonitor = QtGui.QTextEdit() self.bktLogMonitor.setReadOnly(True) self.bktLogMonitor.setMaximumHeight(100) # 设置布局 hbox2 = QtGui.QHBoxLayout() hbox2.addWidget(newButton) hbox2.addWidget(loadButton) hbox2.addStretch() vbox2 = QtGui.QVBoxLayout() vbox2.addWidget(Button1) vbox2.addWidget(Button2) vbox2.addWidget(Button3) vbox2.addWidget(Button4) vbox2.addStretch() hbox3 = QtGui.QHBoxLayout() hbox3.addLayout(vbox2) hbox3.addWidget(self.tabWidget) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox2) vbox.addWidget(self.scrollArea) vbox.setSpacing(20) vbox.addLayout(hbox3) # vbox.addWidget(self.tabWidget) vbox.setSpacing(20) vbox.addWidget(self.bktLogMonitor) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(u'缠论策略') # 金融图 self.PriceW = PriceWidget(self.eventEngine, self.chanlunEngine, self) # 期货代码输入框 self.codeEdit = QtGui.QLineEdit() self.codeEdit.setPlaceholderText(u'在此输入期货代码') self.codeEdit.setMaximumWidth(200) # 按钮 penButton = QtGui.QPushButton(u'分笔') segmentButton = QtGui.QPushButton(u'分段') shopButton = QtGui.QPushButton(u'买卖点') restoreButton = QtGui.QPushButton(u'还原') penButton.clicked.connect(self.pen) segmentButton.clicked.connect(self.segment) shopButton.clicked.connect(self.shop) restoreButton.clicked.connect(self.restore) # Chanlun组件的日志监控 self.chanlunLogMonitor = QtGui.QTextEdit() self.chanlunLogMonitor.setReadOnly(True) self.chanlunLogMonitor.setMaximumHeight(200) # 设置布局 self.hbox2 = QtGui.QHBoxLayout() self.hbox2.addWidget(self.codeEdit) self.hbox2.addWidget(penButton) self.hbox2.addWidget(segmentButton) self.hbox2.addWidget(shopButton) self.hbox2.addWidget(restoreButton) self.hbox2.addStretch() tickButton = QtGui.QPushButton(u'Tick') oneMButton = QtGui.QPushButton(u"1分") fiveMButton = QtGui.QPushButton(u'5分') fifteenMButton = QtGui.QPushButton(u'15分') thirtyMButton = QtGui.QPushButton(u'30分') dayButton = QtGui.QPushButton(u'日') weekButton = QtGui.QPushButton(u'周') monthButton = QtGui.QPushButton(u'月') tickButton.clicked.connect(self.openTick) self.vbox1 = QtGui.QVBoxLayout() self.vbox2 = QtGui.QVBoxLayout() self.vbox1.addWidget(self.PriceW) self.vbox2.addWidget(tickButton) self.vbox2.addWidget(oneMButton) self.vbox2.addWidget(fiveMButton) self.vbox2.addWidget(fifteenMButton) self.vbox2.addWidget(thirtyMButton) self.vbox2.addWidget(dayButton) self.vbox2.addWidget(weekButton) self.vbox2.addWidget(monthButton) self.vbox2.addStretch() self.hbox3 = QtGui.QHBoxLayout() self.hbox3.addStretch() self.hbox3.addLayout(self.vbox1) self.hbox3.addLayout(self.vbox2) self.vbox = QtGui.QVBoxLayout() self.vbox.addLayout(self.hbox2) self.vbox.addLayout(self.hbox3) #vbox.addWidget(self.scrollArea) self.vbox.addWidget(self.chanlunLogMonitor) self.setLayout(self.vbox) self.codeEdit.returnPressed.connect(self.updateSymbol)
def initUi(self): """初始化界面""" self.setWindowTitle(u'行情数据记录工具') # 菜单 lineSelect = QtGui.QLabel(u'需要收集的合约:') buttonSelect = QtGui.QPushButton(u'选择') lineType = QtGui.QLabel(u'合成Bar类型:') barType = ['1m', '5m', '15m', '30m', '60m'] comboType = QtGui.QComboBox() comboType.addItems(barType) lineStart = QtGui.QLabel(u'开始收集:') buttonStart = QtGui.QPushButton(u'收集') buttonSelect.clicked.connect(self.select) buttonStart.clicked.connect(self.start) # 记录合约配置监控 tickLabel = QtGui.QLabel(u'Tick记录') self.tickTable = QtGui.QTableWidget() self.tickTable.setColumnCount(2) self.tickTable.verticalHeader().setVisible(False) self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.tickTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.tickTable.setAlternatingRowColors(True) self.tickTable.setHorizontalHeaderLabels([u'合约代码', u'接口']) barLabel = QtGui.QLabel(u'Bar记录') self.barTable = QtGui.QTableWidget() self.barTable.setColumnCount(2) self.barTable.verticalHeader().setVisible(False) self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.barTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.barTable.setAlternatingRowColors(True) self.barTable.setHorizontalHeaderLabels([u'合约代码', u'接口']) activeLabel = QtGui.QLabel(u'主力合约') self.activeTable = QtGui.QTableWidget() self.activeTable.setColumnCount(2) self.activeTable.verticalHeader().setVisible(False) self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.activeTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.activeTable.setAlternatingRowColors(True) self.activeTable.setHorizontalHeaderLabels([u'主力代码', u'合约代码']) # 日志监控 self.logMonitor = QtGui.QTextEdit() self.logMonitor.setReadOnly(True) self.logMonitor.setMinimumHeight(600) self.logMonitor2 = QtGui.QTextEdit() self.logMonitor2.setReadOnly(True) self.logMonitor2.setMinimumHeight(600) self.logMonitor3 = QtGui.QTextEdit() self.logMonitor3.setReadOnly(True) self.logMonitor3.setMinimumHeight(600) # 设置布局 hbox = QtGui.QHBoxLayout() hbox.addWidget(lineSelect) hbox.addWidget(buttonSelect) hbox.addWidget(lineType) hbox.addWidget(comboType) hbox.addWidget(lineStart) hbox.addWidget(buttonStart) grid = QtGui.QGridLayout() grid.addWidget(tickLabel, 0, 0) grid.addWidget(barLabel, 0, 1) grid.addWidget(activeLabel, 0, 2) grid.addWidget(self.tickTable, 1, 0) grid.addWidget(self.barTable, 1, 1) grid.addWidget(self.activeTable, 1, 2) grid2 = QtGui.QGridLayout() grid2.addWidget(self.logMonitor, 0, 0) grid2.addWidget(self.logMonitor2, 0, 1) grid2.addWidget(self.logMonitor3, 0, 2) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox) vbox.addLayout(grid) vbox.addLayout(grid2) self.setLayout(vbox)
def initUi(self): """初始化界面""" self.setWindowTitle(text.RISK_MANAGER) # 设置界面 self.buttonSwitchEngineStatus = QtGui.QPushButton( text.RISK_MANAGER_STOP) self.spinOrderFlowLimit = RmSpinBox(self.rmEngine.orderFlowLimit) self.spinOrderFlowClear = RmSpinBox(self.rmEngine.orderFlowClear) self.spinOrderSizeLimit = RmSpinBox(self.rmEngine.orderSizeLimit) self.spinTradeLimit = RmSpinBox(self.rmEngine.tradeLimit) self.spinWorkingOrderLimit = RmSpinBox(self.rmEngine.workingOrderLimit) self.spinOrderCancelLimit = RmSpinBox(self.rmEngine.orderCancelLimit) buttonClearOrderFlowCount = QtGui.QPushButton( text.CLEAR_ORDER_FLOW_COUNT) buttonClearTradeCount = QtGui.QPushButton(text.CLEAR_TOTAL_FILL_COUNT) buttonSaveSetting = QtGui.QPushButton(text.SAVE_SETTING) Label = QtGui.QLabel grid = QtGui.QGridLayout() grid.addWidget(Label(text.WORKING_STATUS), 0, 0) grid.addWidget(self.buttonSwitchEngineStatus, 0, 1) grid.addWidget(RmLine(), 1, 0, 1, 2) grid.addWidget(Label(text.ORDER_FLOW_LIMIT), 2, 0) grid.addWidget(self.spinOrderFlowLimit, 2, 1) grid.addWidget(Label(text.ORDER_FLOW_CLEAR), 3, 0) grid.addWidget(self.spinOrderFlowClear, 3, 1) grid.addWidget(RmLine(), 4, 0, 1, 2) grid.addWidget(Label(text.ORDER_SIZE_LIMIT), 5, 0) grid.addWidget(self.spinOrderSizeLimit, 5, 1) grid.addWidget(RmLine(), 6, 0, 1, 2) grid.addWidget(Label(text.TOTAL_TRADE_LIMIT), 7, 0) grid.addWidget(self.spinTradeLimit, 7, 1) grid.addWidget(RmLine(), 8, 0, 1, 2) grid.addWidget(Label(text.WORKING_ORDER_LIMIT), 9, 0) grid.addWidget(self.spinWorkingOrderLimit, 9, 1) grid.addWidget(RmLine(), 10, 0, 1, 2) grid.addWidget(Label(text.CONTRACT_CANCEL_LIMIT), 11, 0) grid.addWidget(self.spinOrderCancelLimit, 11, 1) hbox = QtGui.QHBoxLayout() hbox.addWidget(buttonClearOrderFlowCount) hbox.addWidget(buttonClearTradeCount) hbox.addStretch() hbox.addWidget(buttonSaveSetting) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vbox.addLayout(hbox) self.setLayout(vbox) # 连接组件信号 self.spinOrderFlowLimit.valueChanged.connect( self.rmEngine.setOrderFlowLimit) self.spinOrderFlowClear.valueChanged.connect( self.rmEngine.setOrderFlowClear) self.spinOrderSizeLimit.valueChanged.connect( self.rmEngine.setOrderSizeLimit) self.spinTradeLimit.valueChanged.connect(self.rmEngine.setTradeLimit) self.spinWorkingOrderLimit.valueChanged.connect( self.rmEngine.setWorkingOrderLimit) self.spinOrderCancelLimit.valueChanged.connect( self.rmEngine.setOrderCancelLimit) self.buttonSwitchEngineStatus.clicked.connect(self.switchEngineSatus) buttonClearOrderFlowCount.clicked.connect( self.rmEngine.clearOrderFlowCount) buttonClearTradeCount.clicked.connect(self.rmEngine.clearTradeCount) buttonSaveSetting.clicked.connect(self.rmEngine.saveSetting) # 设为固定大小 self.setFixedSize(self.sizeHint())