Exemplo n.º 1
0
 def initUi(self):
     """"""
     self.setFrameShape(self.Box)
     algoLayout = self.initAlgoLayout()
     
     buttonStart = QtWidgets.QPushButton(u'启动算法')
     buttonStart.clicked.connect(self.addAlgo)
     buttonStart.setMinimumHeight(100)
     
     buttonSave = QtWidgets.QPushButton(u'保存配置')
     buttonSave.clicked.connect(self.saveAlgoSetting)
     buttonSave.setMinimumHeight(100)
     
     self.lineSettingName = QtWidgets.QLineEdit()
     self.lineSettingName.setPlaceholderText(u'算法配置名称')
     
     vbox = QtWidgets.QVBoxLayout()
     vbox.addLayout(algoLayout)
     vbox.addWidget(buttonStart)
     vbox.addWidget(QtWidgets.QLabel(''))
     vbox.addWidget(QtWidgets.QLabel(''))
     vbox.addWidget(self.lineSettingName)
     vbox.addWidget(buttonSave)
     
     self.setLayout(vbox)
Exemplo n.º 2
0
    def initUi(self):
        """"""
        self.setFrameShape(self.Box)
        print 'initSignalLayout():',self.initSignalLayout
        signalLayout = self.initSignalLayout()
        
        buttonStart = QtWidgets.QPushButton(u'启动监控')
        buttonStart.clicked.connect(self.addSignal)
        buttonStart.setMinimumHeight(100)
        
        buttonSave = QtWidgets.QPushButton(u'保存配置')
        buttonSave.clicked.connect(self.saveSignalSetting)
        buttonSave.setMinimumHeight(100)
        
        self.lineSettingName = QtWidgets.QLineEdit()
        self.lineSettingName.setPlaceholderText(u'监控配置名称')
        
        

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(signalLayout)
        vbox.addWidget(buttonStart)
        vbox.addWidget(QtWidgets.QLabel(''))
        vbox.addWidget(QtWidgets.QLabel(''))
        vbox.addWidget(self.lineSettingName)
        vbox.addWidget(buttonSave)
        
        self.setLayout(vbox)
Exemplo n.º 3
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(text.DATA_RECORDER)

        # 记录合约配置监控
        tickLabel = QtWidgets.QLabel(text.TICK_RECORD)
        self.tickTable = QtWidgets.QTableWidget()
        self.tickTable.setColumnCount(2)
        self.tickTable.verticalHeader().setVisible(False)
        self.tickTable.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
        self.tickTable.setAlternatingRowColors(True)
        self.tickTable.setHorizontalHeaderLabels(
            [text.CONTRACT_SYMBOL, text.GATEWAY])

        barLabel = QtWidgets.QLabel(text.BAR_RECORD)
        self.barTable = QtWidgets.QTableWidget()
        self.barTable.setColumnCount(2)
        self.barTable.verticalHeader().setVisible(False)
        self.barTable.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
        self.barTable.setAlternatingRowColors(True)
        self.barTable.setHorizontalHeaderLabels(
            [text.CONTRACT_SYMBOL, text.GATEWAY])

        activeLabel = QtWidgets.QLabel(text.DOMINANT_CONTRACT)
        self.activeTable = QtWidgets.QTableWidget()
        self.activeTable.setColumnCount(2)
        self.activeTable.verticalHeader().setVisible(False)
        self.activeTable.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
        self.activeTable.setAlternatingRowColors(True)
        self.activeTable.setHorizontalHeaderLabels(
            [text.DOMINANT_SYMBOL, text.CONTRACT_SYMBOL])

        # 日志监控
        self.logMonitor = QtWidgets.QTextEdit()
        self.logMonitor.setReadOnly(True)
        self.logMonitor.setMinimumHeight(600)

        # 设置布局
        grid = QtWidgets.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 = QtWidgets.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
Exemplo n.º 4
0
 def initUi(self):
     """初始化界面"""
     self.setWindowTitle(vtText.EDIT_SETTING)
     
     self.comboFileName = QtWidgets.QComboBox()
     self.comboFileName.addItems(jsonPathDict.keys())
     
     buttonLoad = QtWidgets.QPushButton(vtText.LOAD)
     buttonSave = QtWidgets.QPushButton(vtText.SAVE)
     buttonLoad.clicked.connect(self.loadSetting)
     buttonSave.clicked.connect(self.saveSetting)
     
     self.editSetting = QtWidgets.QTextEdit()
     self.labelPath = QtWidgets.QLabel()
     
     hbox = QtWidgets.QHBoxLayout()
     hbox.addWidget(self.comboFileName)
     hbox.addWidget(buttonLoad)
     hbox.addWidget(buttonSave)
     hbox.addStretch()
     
     vbox = QtWidgets.QVBoxLayout()
     vbox.addLayout(hbox)
     vbox.addWidget(self.editSetting)
     vbox.addWidget(self.labelPath)
     
     self.setLayout(vbox)
Exemplo n.º 5
0
 def initUi(self):
     """初始化界面"""
     self.setWindowTitle('RPC服务')
     
     label = QtWidgets.QLabel('该模块运行于服务端')
     vbox = QtWidgets.QVBoxLayout()
     vbox.addWidget(label)
     self.setLayout(vbox)
Exemplo n.º 6
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(vtText.TRADING)
        self.setMaximumWidth(400)
        self.setFrameShape(self.Box)  # 设置边框
        self.setLineWidth(1)

        # 左边部分
        labelSymbol = QtWidgets.QLabel(vtText.CONTRACT_SYMBOL)
        labelName = QtWidgets.QLabel(vtText.CONTRACT_NAME)
        labelDirection = QtWidgets.QLabel(vtText.DIRECTION)
        labelOffset = QtWidgets.QLabel(vtText.OFFSET)
        labelPrice = QtWidgets.QLabel(vtText.PRICE)
        self.checkFixed = QtWidgets.QCheckBox(u'')  # 价格固定选择框
        labelVolume = QtWidgets.QLabel(vtText.VOLUME)
        labelPriceType = QtWidgets.QLabel(vtText.PRICE_TYPE)
        labelExchange = QtWidgets.QLabel(vtText.EXCHANGE)
        labelCurrency = QtWidgets.QLabel(vtText.CURRENCY)
        labelProductClass = QtWidgets.QLabel(vtText.PRODUCT_CLASS)
        labelGateway = QtWidgets.QLabel(vtText.GATEWAY)

        #中间部分
        self.lineSymbol = QtWidgets.QLineEdit()
        self.lineName = QtWidgets.QLineEdit()

        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItems(self.directionList)

        self.comboOffset = QtWidgets.QComboBox()
        self.comboOffset.addItems(self.offsetList)

        self.spinPrice = QtWidgets.QDoubleSpinBox()
        self.spinPrice.setDecimals(4)
        self.spinPrice.setMinimum(0)
        self.spinPrice.setMaximum(100000)

        self.spinVolume = QtWidgets.QSpinBox()
        self.spinVolume.setMinimum(0)
        self.spinVolume.setMaximum(1000000)

        self.comboPriceType = QtWidgets.QComboBox()
        self.comboPriceType.addItems(self.priceTypeList)

        self.comboExchange = QtWidgets.QComboBox()
        self.comboExchange.addItems(self.exchangeList)

        self.comboCurrency = QtWidgets.QComboBox()
        self.comboCurrency.addItems(self.currencyList)

        self.comboProductClass = QtWidgets.QComboBox()
        self.comboProductClass.addItems(self.productClassList)

        self.comboGateway = QtWidgets.QComboBox()
        self.comboGateway.addItems(self.gatewayList)

        gridleft = QtWidgets.QGridLayout()
        gridleft.addWidget(labelSymbol, 0, 0)
        gridleft.addWidget(labelName, 1, 0)
        gridleft.addWidget(labelDirection, 2, 0)
        gridleft.addWidget(labelOffset, 3, 0)
        gridleft.addWidget(labelPrice, 4, 0)
        gridleft.addWidget(labelVolume, 5, 0)
        gridleft.addWidget(labelPriceType, 6, 0)
        gridleft.addWidget(labelExchange, 7, 0)
        gridleft.addWidget(labelCurrency, 8, 0)
        gridleft.addWidget(labelProductClass, 9, 0)
        gridleft.addWidget(labelGateway, 10, 0)

        gridleft.addWidget(self.lineSymbol, 0, 1, 1, -1)
        gridleft.addWidget(self.lineName, 1, 1, 1, -1)
        gridleft.addWidget(self.comboDirection, 2, 1, 1, -1)
        gridleft.addWidget(self.comboOffset, 3, 1, 1, -1)
        gridleft.addWidget(self.checkFixed, 4, 1)
        gridleft.addWidget(self.spinPrice, 4, 2)
        gridleft.addWidget(self.spinVolume, 5, 1, 1, -1)
        gridleft.addWidget(self.comboPriceType, 6, 1, 1, -1)
        gridleft.addWidget(self.comboExchange, 7, 1, 1, -1)
        gridleft.addWidget(self.comboCurrency, 8, 1, 1, -1)
        gridleft.addWidget(self.comboProductClass, 9, 1, 1, -1)
        gridleft.addWidget(self.comboGateway, 10, 1, 1, -1)

        # 右边部分
        labelBid1 = QtWidgets.QLabel(vtText.BID_1)
        labelBid2 = QtWidgets.QLabel(vtText.BID_2)
        labelBid3 = QtWidgets.QLabel(vtText.BID_3)
        labelBid4 = QtWidgets.QLabel(vtText.BID_4)
        labelBid5 = QtWidgets.QLabel(vtText.BID_5)

        labelAsk1 = QtWidgets.QLabel(vtText.ASK_1)
        labelAsk2 = QtWidgets.QLabel(vtText.ASK_2)
        labelAsk3 = QtWidgets.QLabel(vtText.ASK_3)
        labelAsk4 = QtWidgets.QLabel(vtText.ASK_4)
        labelAsk5 = QtWidgets.QLabel(vtText.ASK_5)

        self.labelBidPrice1 = QtWidgets.QLabel()
        self.labelBidPrice2 = QtWidgets.QLabel()
        self.labelBidPrice3 = QtWidgets.QLabel()
        self.labelBidPrice4 = QtWidgets.QLabel()
        self.labelBidPrice5 = QtWidgets.QLabel()
        self.labelBidVolume1 = QtWidgets.QLabel()
        self.labelBidVolume2 = QtWidgets.QLabel()
        self.labelBidVolume3 = QtWidgets.QLabel()
        self.labelBidVolume4 = QtWidgets.QLabel()
        self.labelBidVolume5 = QtWidgets.QLabel()

        self.labelAskPrice1 = QtWidgets.QLabel()
        self.labelAskPrice2 = QtWidgets.QLabel()
        self.labelAskPrice3 = QtWidgets.QLabel()
        self.labelAskPrice4 = QtWidgets.QLabel()
        self.labelAskPrice5 = QtWidgets.QLabel()
        self.labelAskVolume1 = QtWidgets.QLabel()
        self.labelAskVolume2 = QtWidgets.QLabel()
        self.labelAskVolume3 = QtWidgets.QLabel()
        self.labelAskVolume4 = QtWidgets.QLabel()
        self.labelAskVolume5 = QtWidgets.QLabel()

        labelLast = QtWidgets.QLabel(vtText.LAST)
        self.labelLastPrice = QtWidgets.QLabel()
        self.labelReturn = QtWidgets.QLabel()

        self.labelLastPrice.setMinimumWidth(60)
        self.labelReturn.setMinimumWidth(60)

        gridRight = QtWidgets.QGridLayout()
        gridRight.addWidget(labelAsk5, 0, 0)
        gridRight.addWidget(labelAsk4, 1, 0)
        gridRight.addWidget(labelAsk3, 2, 0)
        gridRight.addWidget(labelAsk2, 3, 0)
        gridRight.addWidget(labelAsk1, 4, 0)
        gridRight.addWidget(labelLast, 5, 0)
        gridRight.addWidget(labelBid1, 6, 0)
        gridRight.addWidget(labelBid2, 7, 0)
        gridRight.addWidget(labelBid3, 8, 0)
        gridRight.addWidget(labelBid4, 9, 0)
        gridRight.addWidget(labelBid5, 10, 0)

        gridRight.addWidget(self.labelAskPrice5, 0, 1)
        gridRight.addWidget(self.labelAskPrice4, 1, 1)
        gridRight.addWidget(self.labelAskPrice3, 2, 1)
        gridRight.addWidget(self.labelAskPrice2, 3, 1)
        gridRight.addWidget(self.labelAskPrice1, 4, 1)
        gridRight.addWidget(self.labelLastPrice, 5, 1)
        gridRight.addWidget(self.labelBidPrice1, 6, 1)
        gridRight.addWidget(self.labelBidPrice2, 7, 1)
        gridRight.addWidget(self.labelBidPrice3, 8, 1)
        gridRight.addWidget(self.labelBidPrice4, 9, 1)
        gridRight.addWidget(self.labelBidPrice5, 10, 1)

        gridRight.addWidget(self.labelAskVolume5, 0, 2)
        gridRight.addWidget(self.labelAskVolume4, 1, 2)
        gridRight.addWidget(self.labelAskVolume3, 2, 2)
        gridRight.addWidget(self.labelAskVolume2, 3, 2)
        gridRight.addWidget(self.labelAskVolume1, 4, 2)
        gridRight.addWidget(self.labelReturn, 5, 2)
        gridRight.addWidget(self.labelBidVolume1, 6, 2)
        gridRight.addWidget(self.labelBidVolume2, 7, 2)
        gridRight.addWidget(self.labelBidVolume3, 8, 2)
        gridRight.addWidget(self.labelBidVolume4, 9, 2)
        gridRight.addWidget(self.labelBidVolume5, 10, 2)

        # 发单按钮
        buttonSendOrder = QtWidgets.QPushButton(vtText.SEND_ORDER)
        buttonCancelAll = QtWidgets.QPushButton(vtText.CANCEL_ALL)

        size = buttonSendOrder.sizeHint()
        buttonSendOrder.setMinimumHeight(size.height() * 2)  # 把按钮高度设为默认两倍
        buttonCancelAll.setMinimumHeight(size.height() * 2)

        # 整合布局
        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(gridleft)
        hbox.addLayout(gridRight)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(buttonSendOrder)
        vbox.addWidget(buttonCancelAll)
        vbox.addStretch()

        self.setLayout(vbox)

        # 关联更新
        buttonSendOrder.clicked.connect(self.sendOrder)
        buttonCancelAll.clicked.connect(self.cancelAll)
        self.lineSymbol.returnPressed.connect(self.updateSymbol)
Exemplo n.º 7
0
 def initUi(self):
     """"""
     self.setWindowTitle(u'算法交易')
     
     #buttonWidth = 400
     #buttonHeight = 60        
     
     self.comboTemplate = QtWidgets.QComboBox()
     #self.comboTemplate.setMaximumWidth(buttonWidth)
     self.comboTemplate.currentIndexChanged.connect(self.changeWidget)
     
     vbox = QtWidgets.QVBoxLayout()
     for templateName, widgetClass in WIDGET_DICT.items():
         widget = widgetClass(self.algoEngine)
         #widget.setMaximumWidth(buttonWidth)
         widget.hide()
         vbox.addWidget(widget)
         
         self.widgetDict[templateName] = widget
         self.comboTemplate.addItem(templateName)
     
     self.buttonStop = StopButton(self.algoEngine)
     
     self.buttonAddAlgo = QtWidgets.QPushButton(u'启动篮子算法')
     self.buttonAddAlgo.setStyleSheet("color:white;background-color:green")
     self.buttonAddAlgo.clicked.connect(self.addAlgoFromCsv)
     
     self.buttonSaveSetting = QtWidgets.QPushButton(u'加载算法配置')
     self.buttonSaveSetting.setStyleSheet("color:white;background-color:blue")
     self.buttonSaveSetting.clicked.connect(self.saveSettingFromCsv)
     
     self.lineRepPort = QtWidgets.QLineEdit('8899')
     self.linePubPort = QtWidgets.QLineEdit('9988')
     
     self.buttonStartRpc = QtWidgets.QPushButton(u'启动RPC服务')
     self.buttonStartRpc.setStyleSheet("color:black;background-color:orange")
     self.buttonStartRpc.clicked.connect(self.startRpc)
     
     label = QtWidgets.QLabel(u'算法类型')
     label.setFixedWidth(100)
     
     hbox = QtWidgets.QHBoxLayout()
     hbox.addWidget(label)
     hbox.addWidget(self.comboTemplate)
     
     grid = QtWidgets.QGridLayout()
     grid.addWidget(QtWidgets.QLabel(u'REP端口'), 0, 0)
     grid.addWidget(self.lineRepPort, 0, 1)
     grid.addWidget(QtWidgets.QLabel(u'PUB端口'), 1, 0)
     grid.addWidget(self.linePubPort, 1, 1)
     
     vbox1 = QtWidgets.QVBoxLayout()
     vbox1.addLayout(hbox)
     vbox1.addLayout(vbox)
     vbox1.addStretch()
     vbox1.addWidget(self.buttonStop)
     vbox1.addWidget(self.buttonAddAlgo)
     vbox1.addWidget(self.buttonSaveSetting)
     vbox1.addStretch()
     vbox1.addLayout(grid)
     vbox1.addWidget(self.buttonStartRpc)
     
     workingMonitor = AlgoStatusMonitor(self.algoEngine, AlgoStatusMonitor.MODE_WORKING)
     workingMonitor.setFixedWidth(1500)
     
     historyMonitor = AlgoStatusMonitor(self.algoEngine, AlgoStatusMonitor.MODE_HISTORY)
     logMonitor = AlgoLogMonitor(self.algoEngine)        
     settingMonitor = AlgoSettingMonitor(self.algoEngine)
     
     tab1 = QtWidgets.QTabWidget()
     tab1.addTab(workingMonitor, u'运行中')
     tab1.addTab(historyMonitor, u'已结束')
     
     tab2 = QtWidgets.QTabWidget()
     tab2.addTab(logMonitor, u'日志信息')
     
     tab3 = QtWidgets.QTabWidget()
     tab3.addTab(settingMonitor, u'算法配置')
     
     hbox = QtWidgets.QHBoxLayout()
     hbox.addWidget(tab2)
     hbox.addWidget(tab3)
     
     vbox2 = QtWidgets.QVBoxLayout()
     vbox2.addWidget(tab1)
     vbox2.addLayout(hbox)
     
     hbox2 = QtWidgets.QHBoxLayout()
     hbox2.addLayout(vbox1)
     hbox2.addLayout(vbox2)
     
     self.setLayout(hbox2)
Exemplo n.º 8
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(vtText.TRADING)
        self.setFixedHeight(400)
        self.setFixedWidth(600)
        self.setFrameShape(self.Box)    # 设置边框
        self.setLineWidth(1)           

        # 左边部分
        labelPriceType = QtWidgets.QLabel(vtText.PRICE_TYPE)
        labelSymbol = QtWidgets.QLabel(u'VT代码')
        labelPrice = QtWidgets.QLabel(vtText.PRICE)
        labelVolume = QtWidgets.QLabel(u'数量')
        labelOffset = QtWidgets.QLabel(vtText.OFFSET)
        
        self.comboPriceType = QtWidgets.QComboBox()
        self.comboPriceType.addItems(self.priceTypeList)
        
        self.lineSymbol = QtWidgets.QLineEdit()
        
        validator = QtGui.QDoubleValidator()
        validator.setBottom(0)        

        self.linePrice = QtWidgets.QLineEdit()
        self.linePrice.setValidator(validator)
        
        self.lineVolume = QtWidgets.QLineEdit()
        self.lineVolume.setValidator(validator)

        self.comboOffset = QtWidgets.QComboBox()
        self.comboOffset.addItems(self.offsetList)
        
        gridLeft = QtWidgets.QGridLayout()
        gridLeft.addWidget(labelPriceType, 0, 0)
        gridLeft.addWidget(labelSymbol, 1, 0)
        gridLeft.addWidget(labelPrice, 2, 0)
        gridLeft.addWidget(labelVolume, 3, 0)
        gridLeft.addWidget(labelOffset, 4, 0)
        
        gridLeft.addWidget(self.comboPriceType, 0, 1)
        gridLeft.addWidget(self.lineSymbol, 1, 1)
        gridLeft.addWidget(self.linePrice, 2, 1)
        gridLeft.addWidget(self.lineVolume, 3, 1)
        gridLeft.addWidget(self.comboOffset, 4, 1)
        
        # 右边部分
        self.depthMonitor = DepthMonitor(self.mainEngine, self.eventEngine)

        # 发单按钮
        buttonBuy = QtWidgets.QPushButton(u'买/多')
        buttonSell = QtWidgets.QPushButton(u'卖/空')
        buttonCancelAll = QtWidgets.QPushButton(vtText.CANCEL_ALL)
        
        size = buttonBuy.sizeHint()
        buttonBuy.setMinimumHeight(size.height()*2)
        buttonSell.setMinimumHeight(size.height()*2)
        buttonCancelAll.setMinimumHeight(size.height()*2)
        
        buttonBuy.clicked.connect(self.sendBuyOrder)
        buttonSell.clicked.connect(self.sendSellOrder)
        buttonCancelAll.clicked.connect(self.cancelAll)
        
        buttonBuy.setStyleSheet('color:white;background-color:red')
        buttonSell.setStyleSheet('color:white;background-color:green')
        buttonCancelAll.setStyleSheet('color:black;background-color:yellow')
        
        gridButton = QtWidgets.QGridLayout()
        gridButton.addWidget(buttonBuy, 0, 0)
        gridButton.addWidget(buttonSell, 0, 1)
        gridButton.addWidget(buttonCancelAll, 1, 0, 1, 2)
        
        # 整合布局
        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(gridLeft)
        vbox.addLayout(gridButton)
        
        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(vbox)
        hbox.addWidget(self.depthMonitor)
        
        self.setLayout(hbox)

        # 关联更新
        self.lineSymbol.returnPressed.connect(self.updateSymbol)
        self.depthMonitor.itemDoubleClicked.connect(self.updatePrice)