示例#1
0
 def initStrategyManager(self):
     """初始化策略管理组件界面"""        
     w = QtWidgets.QWidget()
     vbox = QtWidgets.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)   
示例#2
0
 def initUi(self):
     """初始化界面"""
     self.setWindowTitle(text.CTA_STRATEGY)
     
     # 按钮
     loadButton = QtWidgets.QPushButton(text.LOAD_STRATEGY)
     initAllButton = QtWidgets.QPushButton(text.INIT_ALL)
     startAllButton = QtWidgets.QPushButton(text.START_ALL)
     stopAllButton = QtWidgets.QPushButton(text.STOP_ALL)
     savePositionButton = QtWidgets.QPushButton(text.SAVE_POSITION_DATA)
     
     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 = QtWidgets.QScrollArea()
     self.scrollArea.setWidgetResizable(True)
     
     # CTA组件的日志监控
     self.ctaLogMonitor = QtWidgets.QTextEdit()
     self.ctaLogMonitor.setReadOnly(True)
     self.ctaLogMonitor.setMaximumHeight(200)
     
     # 设置布局
     hbox2 = QtWidgets.QHBoxLayout()
     hbox2.addWidget(loadButton)
     hbox2.addWidget(initAllButton)
     hbox2.addWidget(startAllButton)
     hbox2.addWidget(stopAllButton)
     hbox2.addWidget(savePositionButton)
     hbox2.addStretch()
     
     vbox = QtWidgets.QVBoxLayout()
     vbox.addLayout(hbox2)
     vbox.addWidget(self.scrollArea)
     vbox.addWidget(self.ctaLogMonitor)
     self.setLayout(vbox)
示例#3
0
    def updateData(self, data):
        """更新数据"""
        if not self.inited:
            self.setColumnCount(len(data))
            self.setHorizontalHeaderLabels(data.keys())

            col = 0
            for k, v in data.items():
                cell = QtWidgets.QTableWidgetItem(unicode(v))
                self.keyCellDict[k] = cell
                self.setItem(0, col, cell)
                col += 1

            self.inited = True
        else:
            for k, v in data.items():
                cell = self.keyCellDict[k]
                cell.setText(unicode(v))
示例#4
0
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        self.paramMonitor = CtaValueMonitor(self)
        self.varMonitor = CtaValueMonitor(self)

        height = 65
        self.paramMonitor.setFixedHeight(height)
        self.varMonitor.setFixedHeight(height)

        buttonInit = QtWidgets.QPushButton(text.INIT)
        buttonStart = QtWidgets.QPushButton(text.START)
        buttonStop = QtWidgets.QPushButton(text.STOP)
        buttonInit.clicked.connect(self.init)
        buttonStart.clicked.connect(self.start)
        buttonStop.clicked.connect(self.stop)

        hbox1 = QtWidgets.QHBoxLayout()
        hbox1.addWidget(buttonInit)
        hbox1.addWidget(buttonStart)
        hbox1.addWidget(buttonStop)
        hbox1.addStretch()

        hbox2 = QtWidgets.QHBoxLayout()
        hbox2.addWidget(self.paramMonitor)

        hbox3 = QtWidgets.QHBoxLayout()
        hbox3.addWidget(self.varMonitor)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)

        self.setLayout(vbox)
示例#5
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(text.RISK_MANAGER)

        # 设置界面
        self.buttonSwitchEngineStatus = QtWidgets.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 = QtWidgets.QPushButton(
            text.CLEAR_ORDER_FLOW_COUNT)
        buttonClearTradeCount = QtWidgets.QPushButton(
            text.CLEAR_TOTAL_FILL_COUNT)
        buttonSaveSetting = QtWidgets.QPushButton(text.SAVE_SETTING)

        Label = QtWidgets.QLabel
        grid = QtWidgets.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 = QtWidgets.QHBoxLayout()
        hbox.addWidget(buttonClearOrderFlowCount)
        hbox.addWidget(buttonClearTradeCount)
        hbox.addStretch()
        hbox.addWidget(buttonSaveSetting)

        vbox = QtWidgets.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())