def __init__(self, name=None, direction=None, vtSymbol=None, CtaEngineManager=None): super(ParamWindow2, self).__init__() self.resize(350, 480) self.ce = CtaEngineManager self.saveButton = QtGui.QPushButton(u"保存", self) self.cancelButton = QtGui.QPushButton(u"取消", self) self.setWindowTitle(u"参数") self.vtSymbol = vtSymbol self.setting = {} self.paramters = {} self.strategyName = "" self.name = name self.firstSave = True self.fileName = "" if name != "": self.fileName = "parameter_" + name + ".json" path = os.path.abspath(os.path.dirname(__file__)) self.fileName = os.path.join(path, self.fileName) self.center() self.onInit()
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): 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.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(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 __init__(self, analysisEngine): # 初始化方法 QtGui.QWidget.__init__(self) # 调用父类初始化方法 self.setWindowTitle('NetCurve') # 设置窗口标题 self.path = os.getcwd() + '/ctaLogFile/ctaPosFile' # self.path = os.getcwd() + '/statement/netSource' self.analysisEngine = analysisEngine # self.resize(300,200) # 设置窗口大小 gridlayout = QtGui.QGridLayout() # 创建布局组件 self.cbAccount = QtGui.QComboBox() self.cbContract = QtGui.QComboBox() self.buttonStart = QtGui.QPushButton() self.lineedit = QtGui.QLineEdit('1000000') self.labelAcct = QtGui.QLabel(u'账户') self.labelCon = QtGui.QLabel(u'标的') self.labelAmount = QtGui.QLabel(u'初始金额') self.labelEvaluate = QtGui.QLabel() tree = lambda: collections.defaultdict(tree) self.dataList = tree() self.fileName = [] self.loadAllPosFile() self.cbAccount.addItems( [k for k in self.groupByPosFile('name').keys()]) self.cbContract.addItems( [k for k in self.groupByPosFile('contract').keys()])
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.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 __init__(self, ParamWindow, ParamWindow2, ParamWindow3, CtaEngineManager=None): super(strategyWindow, self).__init__() self.setWindowTitle(u"策略类型") self.pw = ParamWindow self.gt = ParamWindow2 self.cai = ParamWindow3 self.ce = CtaEngineManager self.tradeTestButton = QtGui.QPushButton(u"配置双合约套利策略", self) self.tradeTestButton.clicked.connect(self.createTradeTest) self.girdTradingButton = QtGui.QPushButton(u"配置单合约网格策略", self) self.girdTradingButton.clicked.connect(self.createGirdTrading) self.CtpAndIB = QtGui.QPushButton(u"配置CTP IB套利策略", self) self.CtpAndIB.clicked.connect(self.createCtpAndIB) self.moreStrategyCoding = QtGui.QPushButton(u"更多策略开发中", self) self.moreStrategyCoding.clicked.connect(self.coding) self.initUI()
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 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.setWindowTitle(u'缠论策略') # 按钮 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) # 滚动区域,放置所有的ChanlunStrategyManager self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) # Chanlun组件的日志监控 self.chanlunLogMonitor = QtGui.QTextEdit() self.chanlunLogMonitor.setReadOnly(True) self.chanlunLogMonitor.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.chanlunLogMonitor) 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): """初始化界面""" 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'风险管理') # 设置界面 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(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(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) btnEdit = QtGui.QPushButton(u'编辑', self) vbox = QtGui.QVBoxLayout() vbox.addLayout(grid) vline = QtGui.QHBoxLayout() vline.addWidget(btnEdit) vbox.addLayout(vline) vbox.addWidget(self.logMonitor) self.setLayout(vbox) btnEdit.clicked.connect(self.openDr)
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'风险管理') # 设置界面 self.buttonSwitchEngineStatus = QtGui.QPushButton(u'风控模块未启动') # self.spinaccountMarginRatio = RmSpinBox(self.rmEngine.accountMarginRatio) # self.spintradeCountLimit = RmSpinBox(self.rmEngine.tradeCountLimit) # self.spinstrategyInstanceOpenLimit = RmSpinBox(self.rmEngine.strategyInstanceOpenLimit) # self.spinstrategyInstancePositionLimit = RmSpinBox(self.rmEngine.strategyInstancePositionLimit) # self.spincontractPositionLimit = RmSpinBox(self.rmEngine.contractPositionLimit) # 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.spinaccountMarginRatio, 2, 1) # # grid.addWidget(Label(u'流控清空(秒)'), 3, 0) # # grid.addWidget(self.spinOrderFlowClear, 3, 1) # grid.addWidget(RmLine(), 3, 0, 1, 2) # grid.addWidget(Label(u'单日累计交易次数上限'), 4, 0) # grid.addWidget(self.spintradeCountLimit, 4, 1) # grid.addWidget(RmLine(), 5, 0, 1, 2) # grid.addWidget(Label(u'单策略实例开仓上限'), 6, 0) # grid.addWidget(self.spinstrategyInstanceOpenLimit, 6, 1) # grid.addWidget(RmLine(), 7, 0, 1, 2) # grid.addWidget(Label(u'单策略实例持仓上限'), 8, 0) # grid.addWidget(self.spinstrategyInstancePositionLimit, 8, 1) # hbox = QtGui.QHBoxLayout() # hbox.addWidget(buttonSwitchEngineStatus) # hbox.addWidget(buttonClearTradeCount) # hbox.addStretch() # hbox.addWidget(buttonSaveSetting) # vbox = QtGui.QVBoxLayout() # vbox.addLayout(grid) # vbox.addLayout(hbox) # self.setLayout(vbox) # # 连接组件信号 # self.spinaccountMarginRatio.valueChanged.connect(self.rmEngine.setAccountMarginRatio) # self.spintradeCountLimit.valueChanged.connect(self.rmEngine.setTradeCountLimit) # self.spinstrategyInstanceOpenLimit.valueChanged.connect(self.rmEngine.setStrategyInstanceOpenLimit) # self.spinstrategyInstancePositionLimit.valueChanged.connect(self.rmEngine.setStrategyInstancePositionLimit) # self.spincontractPositionLimit.valueChanged.connect(self.rmEngine.setContractPositionLimit) # self.buttonSwitchEngineStatus.clicked.connect(self.switchEngineStatus) # buttonClearOrderFlowCount.clicked.connect(self.rmEngine.clearOrderFlowCount) # buttonClearTradeCount.clicked.connect(self.rmEngine.clearTradeCount) # buttonSaveSetting.clicked.connect(self.rmEngine.saveSetting) buttonHBox = QtGui.QHBoxLayout() buttonHBox.addStretch() buttonHBox.addWidget(self.buttonSwitchEngineStatus) grid = QtGui.QGridLayout() grid.addLayout(buttonHBox, 0, 0, 1, 1) self.setLayout(grid) # 设为固定大小 self.setFixedSize(self.sizeHint())
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())