コード例 #1
0
ファイル: stAlgo.py プロジェクト: pyctp/vnpurectp
    def initAlgoLayout(self):
        """"""
        self.lineSymbol = QtWidgets.QLineEdit()

        self.spinVolume = QtWidgets.QDoubleSpinBox()
        self.spinVolume.setMinimum(0)
        self.spinVolume.setMaximum(1000000000)
        self.spinVolume.setDecimals(6)

        self.spinInterval = QtWidgets.QSpinBox()
        self.spinInterval.setMinimum(20)
        self.spinInterval.setMaximum(3600)

        self.spinMinTickSpread = QtWidgets.QSpinBox()
        self.spinMinTickSpread.setMinimum(0)
        self.spinMinTickSpread.setMaximum(1000)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineSymbol, 0, 1)
        grid.addWidget(Label(u'单次刷单量'), 1, 0)
        grid.addWidget(self.spinVolume, 1, 1)
        grid.addWidget(Label(u'执行间隔'), 2, 0)
        grid.addWidget(self.spinInterval, 2, 1)
        grid.addWidget(Label(u'最小价差Tick'), 3, 0)
        grid.addWidget(self.spinMinTickSpread, 3, 1)

        return grid
コード例 #2
0
    def initUi(self):
        """"""
        self.setWindowTitle(u'算法交易')

        self.statusMonitor = AlgoStatusMonitor(self.algoEngine)
        self.logMonitor = AlgoLogMonitor(self.algoEngine)
        self.tab = QtWidgets.QTabWidget()
        self.buttonStop = StopButton(self.algoEngine)

        self.tab.setMaximumWidth(400)
        self.buttonStop.setMaximumWidth(400)
        self.buttonStop.setFixedHeight(100)

        vbox1 = QtWidgets.QVBoxLayout()
        vbox1.addWidget(self.tab)
        vbox1.addStretch()
        vbox1.addWidget(self.buttonStop)

        vbox2 = QtWidgets.QVBoxLayout()
        vbox2.addWidget(self.statusMonitor)
        vbox2.addWidget(self.logMonitor)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(vbox1)
        hbox.addLayout(vbox2)

        self.setLayout(hbox)
コード例 #3
0
    def initAlgoLayout(self):
        """"""
        self.lineSymbol = QtWidgets.QLineEdit()

        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItem(DIRECTION_LONG)
        self.comboDirection.addItem(DIRECTION_SHORT)
        self.comboDirection.setCurrentIndex(0)

        self.spinPrice = QtWidgets.QDoubleSpinBox()
        self.spinPrice.setMinimum(0)
        self.spinPrice.setMaximum(1000000000)
        self.spinPrice.setDecimals(8)

        self.spinVolume = QtWidgets.QDoubleSpinBox()
        self.spinVolume.setMinimum(0)
        self.spinVolume.setMaximum(1000000000)
        self.spinVolume.setDecimals(0)
        self.spinVolume.setValue(1)

        self.comboOffset = QtWidgets.QComboBox()
        self.comboOffset.addItems(['', OFFSET_OPEN, OFFSET_CLOSE])
        self.comboOffset.setCurrentIndex(0)

        self.spinPotsize = QtWidgets.QDoubleSpinBox()
        self.spinPotsize.setMinimum(0)
        self.spinPotsize.setValue(4)
        self.spinPotsize.setMaximum(1000)
        self.spinPotsize.setDecimals(0)

        self.spinFailval = QtWidgets.QDoubleSpinBox()
        self.spinFailval.setMinimum(0)
        self.spinFailval.setMaximum(1000)
        self.spinFailval.setDecimals(0)

        self.spinGoodval = QtWidgets.QDoubleSpinBox()
        self.spinGoodval.setMinimum(0)
        self.spinGoodval.setMaximum(1000)
        self.spinGoodval.setDecimals(0)

        buttonStart = QtWidgets.QPushButton(u'启动')
        buttonStart.clicked.connect(self.addAlgo)
        buttonStart.setMinimumHeight(100)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineSymbol, 0, 1)

        grid.addWidget(Label(u'点大小'), 1, 0)
        grid.addWidget(self.spinPotsize, 1, 1)

        grid.addWidget(Label(u'方向'), 2, 0)
        grid.addWidget(self.comboDirection, 2, 1)

        grid.addWidget(Label(u'数量'), 3, 0)
        grid.addWidget(self.spinVolume, 3, 1)

        return grid
コード例 #4
0
ファイル: uiStWidget.py プロジェクト: bubble501/_Hack
 def initCells(self):
     """初始化单元格"""
     algoEngine = self.algoEngine
     
     l = self.algoEngine.getAllAlgoParams()
     self.setRowCount(len(l))
     
     for row, d in enumerate(l):            
         cellSpreadName = QtWidgets.QTableWidgetItem(d['spreadName'])
         cellAlgoName = QtWidgets.QTableWidgetItem(d['algoName'])
         spinBuyPrice = StBuyPriceSpinBox(algoEngine, d['spreadName'], d['buyPrice'])
         spinSellPrice = StSellPriceSpinBox(algoEngine, d['spreadName'], d['sellPrice'])
         spinShortPrice = StShortPriceSpinBox(algoEngine, d['spreadName'], d['shortPrice'])
         spinCoverPrice = StCoverPriceSpinBox(algoEngine, d['spreadName'], d['coverPrice'])
         spinMaxOrderSize = StMaxOrderSizeSpinBox(algoEngine, d['spreadName'], d['maxOrderSize'])
         spinMaxPosSize = StMaxPosSizeSpinBox(algoEngine, d['spreadName'], d['maxPosSize'])
         comboMode = StModeComboBox(algoEngine, d['spreadName'], d['mode'])
         buttonActive = StActiveButton(algoEngine, d['spreadName'])
         
         self.setItem(row, 0, cellSpreadName)
         self.setItem(row, 1, cellAlgoName)
         self.setCellWidget(row, 2, spinBuyPrice)
         self.setCellWidget(row, 3, spinSellPrice)
         self.setCellWidget(row, 4, spinCoverPrice)
         self.setCellWidget(row, 5, spinShortPrice)
         self.setCellWidget(row, 6, spinMaxOrderSize)
         self.setCellWidget(row, 7, spinMaxPosSize)
         self.setCellWidget(row, 8, comboMode)
         self.setCellWidget(row, 9, buttonActive)
         
         buttonActive.signalActive.connect(comboMode.algoActiveChanged)
         
         self.buttonActiveDict[d['spreadName']] = buttonActive
コード例 #5
0
 def loadCalendar(self):
     """读取日历"""
     self.clearContents()
     
     row = 0
     totalRow = self.rowCount()
     
     # 如果有则打开
     try:
         with open(CALENDAR_FILEPATH, 'r') as f:
             reader = csv.DictReader(f)
             for d in reader:
                 cellDate = QtWidgets.QTableWidgetItem(d['date'])
                 cellDescription = QtWidgets.QTableWidgetItem(d['description'])
                 
                 if row >= totalRow:
                     self.insertRow(row)
     
                 self.setItem(row, 0, cellDate)
                 self.setItem(row, 1, cellDescription)
                 
                 row = row + 1                    
                 
     # 如果没有该文件则创建
     except IOError:
         f = open(CALENDAR_FILEPATH, 'w')
         f.close()
コード例 #6
0
ファイル: uiRsWidget.py プロジェクト: wenjiandu/vnpy_fxdayu
 def initUi(self):
     """初始化界面"""
     self.setWindowTitle('RPC服务')
     
     label = QtWidgets.QLabel('该模块运行于服务端')
     vbox = QtWidgets.QVBoxLayout()
     vbox.addWidget(label)
     self.setLayout(vbox)
コード例 #7
0
    def initMenu(self):
        """初始化右键菜单"""
        self.menu = QtWidgets.QMenu(self)

        saveAction = QtWidgets.QAction(vtText.SAVE_DATA, self)
        saveAction.triggered.connect(self.saveToCsv)

        self.menu.addAction(saveAction)
コード例 #8
0
ファイル: uiRtdWidget.py プロジェクト: gongkai90000/2010test
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'RTD服务')

        self.logMonitor = QtWidgets.QTextBrowser()

        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.logMonitor)

        self.setLayout(vbox)
コード例 #9
0
 def initMenu(self):
     """初始化右键菜单"""
     self.menu = QtWidgets.QMenu(self)    
     
     resizeAction = QtWidgets.QAction(vtText.RESIZE_COLUMNS, self)
     resizeAction.triggered.connect(self.resizeColumns)        
     
     saveAction = QtWidgets.QAction(vtText.SAVE_DATA, self)
     saveAction.triggered.connect(self.saveToCsv)
     
     self.menu.addAction(resizeAction)
     self.menu.addAction(saveAction)
コード例 #10
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle('Jaqs服务')
        # 日志监控
        self.logMonitor = QtWidgets.QTextEdit()
        self.logMonitor.setReadOnly(True)
        self.logMonitor.setMinimumHeight(600)

        # 设置布局
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
コード例 #11
0
ファイル: twapAlgo.py プロジェクト: Ye980226/api_fxdayu
 def initUi(self):
     """"""
     self.lineSymbol = QtWidgets.QLineEdit()
     
     self.comboDirection = QtWidgets.QComboBox()
     self.comboDirection.addItem(DIRECTION_LONG)
     self.comboDirection.addItem(DIRECTION_SHORT)
     self.comboDirection.setCurrentIndex(0)
     
     self.spinPrice = QtWidgets.QDoubleSpinBox()
     self.spinPrice.setMinimum(0)
     self.spinPrice.setMaximum(1000000000)
     self.spinPrice.setDecimals(8)
     
     self.spinVolume = QtWidgets.QDoubleSpinBox()
     self.spinVolume.setMinimum(0)
     self.spinVolume.setMaximum(1000000000)
     self.spinVolume.setDecimals(6)
     
     self.spinTime = QtWidgets.QSpinBox()
     self.spinTime.setMinimum(30)
     self.spinTime.setMaximum(86400)
     
     self.spinInterval = QtWidgets.QSpinBox()
     self.spinInterval.setMinimum(10)
     self.spinInterval.setMaximum(3600)
     
     self.spinMinVolume = QtWidgets.QDoubleSpinBox()
     self.spinMinVolume.setMinimum(0)
     self.spinMinVolume.setMaximum(10000)
     self.spinMinVolume.setDecimals(6)
     self.spinMinVolume.setValue(1)
     
     buttonStart = QtWidgets.QPushButton(u'启动')
     buttonStart.clicked.connect(self.addAlgo)
     buttonStart.setMinimumHeight(100)
     
     Label = QtWidgets.QLabel
     
     grid = QtWidgets.QGridLayout()
     grid.addWidget(Label(u'交易代码'), 0, 0)
     grid.addWidget(self.lineSymbol, 0, 1)
     grid.addWidget(Label(u'方向'), 1, 0)
     grid.addWidget(self.comboDirection, 1, 1)
     grid.addWidget(Label(u'目标价格'), 2, 0)
     grid.addWidget(self.spinPrice, 2, 1)
     grid.addWidget(Label(u'总数量'), 3, 0)
     grid.addWidget(self.spinVolume, 3, 1)
     grid.addWidget(Label(u'总时间(秒)'), 4, 0)
     grid.addWidget(self.spinTime, 4, 1)
     grid.addWidget(Label(u'间隔(秒)'), 5, 0)
     grid.addWidget(self.spinInterval, 5, 1)
     grid.addWidget(Label(u'数量取整'), 6, 0)
     grid.addWidget(self.spinMinVolume, 6, 1)
     grid.addWidget(buttonStart, 7, 0, 1, 2)
     
     self.setLayout(grid)
コード例 #12
0
    def initCells(self):
        """初始化单元格"""
        algoEngine = self.algoEngine

        l = self.algoEngine.getAllAlgoParams()

        for d in l:
            self.insertRow(0)

            cellSpreadName = QtWidgets.QTableWidgetItem(d['spreadName'])
            cellAlgoName = QtWidgets.QTableWidgetItem(d['algoName'])
            cellNetPos = QtWidgets.QTableWidgetItem('0')
            spinBuyPrice = StBuyPriceSpinBox(algoEngine, d['spreadName'],
                                             d['buyPrice'])
            spinSellPrice = StSellPriceSpinBox(algoEngine, d['spreadName'],
                                               d['sellPrice'])
            spinShortPrice = StShortPriceSpinBox(algoEngine, d['spreadName'],
                                                 d['shortPrice'])
            spinCoverPrice = StCoverPriceSpinBox(algoEngine, d['spreadName'],
                                                 d['coverPrice'])
            spinMaxOrderSize = StMaxOrderSizeSpinBox(algoEngine,
                                                     d['spreadName'],
                                                     d['maxOrderSize'])
            spinMaxPosSize = StMaxPosSizeSpinBox(algoEngine, d['spreadName'],
                                                 d['maxPosSize'])
            comboMode = StModeComboBox(algoEngine, d['spreadName'], d['mode'])
            buttonActive = StActiveButton(algoEngine, d['spreadName'])

            self.setItem(0, 0, cellSpreadName)
            self.setItem(0, 1, cellAlgoName)
            self.setItem(0, 2, cellNetPos)
            self.setCellWidget(0, 3, spinBuyPrice)
            self.setCellWidget(0, 4, spinSellPrice)
            self.setCellWidget(0, 5, spinCoverPrice)
            self.setCellWidget(0, 6, spinShortPrice)
            self.setCellWidget(0, 7, spinMaxOrderSize)
            self.setCellWidget(0, 8, spinMaxPosSize)
            self.setCellWidget(0, 9, comboMode)
            self.setCellWidget(0, 10, buttonActive)

            buttonActive.signalActive.connect(spinBuyPrice.algoActiveChanged)
            buttonActive.signalActive.connect(spinSellPrice.algoActiveChanged)
            buttonActive.signalActive.connect(spinShortPrice.algoActiveChanged)
            buttonActive.signalActive.connect(spinCoverPrice.algoActiveChanged)
            buttonActive.signalActive.connect(
                spinMaxOrderSize.algoActiveChanged)
            buttonActive.signalActive.connect(spinMaxPosSize.algoActiveChanged)
            buttonActive.signalActive.connect(comboMode.algoActiveChanged)

            self.buttonActiveDict[d['spreadName']] = buttonActive
            self.posCellDict[d['spreadName']] = cellNetPos
コード例 #13
0
    def initAlgoLayout(self):
        """"""
        self.lineVtSymbol = QtWidgets.QLineEdit()

        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItem(DIRECTION_LONG)
        self.comboDirection.addItem(DIRECTION_SHORT)
        self.comboDirection.setCurrentIndex(0)

        doubleValidator = QtGui.QDoubleValidator()
        doubleValidator.setBottom(0)

        intValidator = QtGui.QIntValidator()
        intValidator.setBottom(1)

        self.linePrice = QtWidgets.QLineEdit()
        self.linePrice.setValidator(doubleValidator)

        self.lineVolume = QtWidgets.QLineEdit()
        self.lineVolume.setValidator(doubleValidator)

        self.lineDisplay = QtWidgets.QLineEdit()
        self.lineDisplay.setValidator(doubleValidator)

        self.lineInterval = QtWidgets.QLineEdit()
        self.lineInterval.setValidator(intValidator)

        self.comboOffset = QtWidgets.QComboBox()
        self.comboOffset.addItems(['', OFFSET_OPEN, OFFSET_CLOSE])
        self.comboOffset.setCurrentIndex(0)

        buttonStart = QtWidgets.QPushButton(u'启动')
        buttonStart.clicked.connect(self.addAlgo)
        buttonStart.setMinimumHeight(100)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineVtSymbol, 0, 1)
        grid.addWidget(Label(u'方向'), 1, 0)
        grid.addWidget(self.comboDirection, 1, 1)
        grid.addWidget(Label(u'价格'), 2, 0)
        grid.addWidget(self.linePrice, 2, 1)
        grid.addWidget(Label(u'数量'), 3, 0)
        grid.addWidget(self.lineVolume, 3, 1)
        grid.addWidget(Label(u'挂出数量'), 4, 0)
        grid.addWidget(self.lineDisplay, 4, 1)
        grid.addWidget(Label(u'运行间隔'), 5, 0)
        grid.addWidget(self.lineInterval, 5, 1)
        grid.addWidget(Label(u'开平'), 6, 0)
        grid.addWidget(self.comboOffset, 6, 1)

        return grid
コード例 #14
0
ファイル: sniperAlgo.py プロジェクト: fswzb/vnpy20
    def initAlgoLayout(self):
        """"""
        self.lineVtSymbol = QtWidgets.QLineEdit()

        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItem(DIRECTION_LONG)
        self.comboDirection.addItem(DIRECTION_SHORT)
        self.comboDirection.setCurrentIndex(0)

        doubleValidator = QtGui.QDoubleValidator()
        doubleValidator.setBottom(0)

        self.linePrice = QtWidgets.QLineEdit()
        self.linePrice.setValidator(doubleValidator)

        self.comboClosePips = QtWidgets.QComboBox()
        self.comboClosePips.addItems(['2', '3', '4', '5', '6', '7', '8', '9'])
        self.comboClosePips.setCurrentIndex(4)
        self.comboStopPips = QtWidgets.QComboBox()
        self.comboStopPips.addItems(['2', '3', '4', '5', '6', '7', '8', '9'])
        self.comboStopPips.setCurrentIndex(2)

        self.lineVolume = QtWidgets.QLineEdit()
        self.lineVolume.setValidator(doubleValidator)

        self.comboPrePips = QtWidgets.QComboBox()
        self.comboPrePips.addItems(['2', '3', '4', '5', '6', '7', '8', '9'])
        self.comboPrePips.setCurrentIndex(0)

        buttonStart = QtWidgets.QPushButton(u'启动')
        buttonStart.clicked.connect(self.addAlgo)
        buttonStart.setMinimumHeight(100)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineVtSymbol, 0, 1)
        grid.addWidget(Label(u'方向'), 1, 0)
        grid.addWidget(self.comboDirection, 1, 1)
        grid.addWidget(Label(u'价格'), 2, 0)
        grid.addWidget(self.linePrice, 2, 1)
        grid.addWidget(Label(u'数量'), 3, 0)
        grid.addWidget(self.lineVolume, 3, 1)
        grid.addWidget(Label(u'提前跳'), 4, 0)
        grid.addWidget(self.comboPrePips, 4, 1)
        grid.addWidget(Label(u'止盈跳'), 5, 0)
        grid.addWidget(self.comboClosePips, 5, 1)
        grid.addWidget(Label(u'止损跳'), 6, 0)
        grid.addWidget(self.comboStopPips, 6, 1)

        return grid
コード例 #15
0
    def __init__(self, widget, title, parent=None):
        """Constructor"""
        super(StGroup, self).__init__(parent)

        self.setTitle(title)
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(widget)
        self.setLayout(vbox)
コード例 #16
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)
コード例 #17
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)
コード例 #18
0
    def initSignalLayout(self):
        """"""
 
        self.lineSymbol = QtWidgets.QLineEdit()
        
        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItem(DIRECTION_LONG)
        self.comboDirection.addItem(DIRECTION_SHORT)
        self.comboDirection.setCurrentIndex(0)
        
        self.spinPrice = QtWidgets.QDoubleSpinBox()
        self.spinPrice.setMinimum(0)
        self.spinPrice.setMaximum(1000000000)
        self.spinPrice.setDecimals(8)
        
        self.spinVolume = QtWidgets.QDoubleSpinBox()
        self.spinVolume.setMinimum(0)
        self.spinVolume.setMaximum(1000000000)
        self.spinVolume.setDecimals(0)
        
        self.comboOffset = QtWidgets.QComboBox()
        self.comboOffset.addItems(['', OFFSET_OPEN, OFFSET_CLOSE])
        self.comboOffset.setCurrentIndex(0)
        
        self.spinPriceAdd = QtWidgets.QDoubleSpinBox()
        self.spinPriceAdd.setMinimum(0)
        self.spinPriceAdd.setMaximum(1000000000)
        self.spinPriceAdd.setDecimals(8)        
        
        buttonStart = QtWidgets.QPushButton(u'启动')
        buttonStart.clicked.connect(self.addSignal)
        buttonStart.setMinimumHeight(100)
        
        Label = QtWidgets.QLabel
        
        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineSymbol, 0, 1)
        # grid.addWidget(Label(u'方向'), 1, 0)
        # grid.addWidget(self.comboDirection, 1, 1)

        # grid.addWidget(Label(u'价格'), 2, 0)
        # grid.addWidget(self.spinPrice, 2, 1)
        grid.addWidget(Label(u'数量'), 3, 0)
        grid.addWidget(self.spinVolume, 3, 1)
        # grid.addWidget(Label(u'开平'), 4, 0)
        # grid.addWidget(self.comboOffset, 4, 1)
        # grid.addWidget(Label(u'超价'), 5, 0)
        # grid.addWidget(self.spinPriceAdd, 5, 1)        
        
        print 'bt. initSignalLayout():',grid
        return grid
コード例 #19
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(vtText.CONTRACT_SEARCH)

        self.lineFilter = QtWidgets.QLineEdit()
        self.buttonFilter = QtWidgets.QPushButton(vtText.SEARCH)
        self.buttonFilter.clicked.connect(self.filterContract)
        self.monitor = ContractMonitor(self.mainEngine)
        self.monitor.refresh()

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.lineFilter)
        hbox.addWidget(self.buttonFilter)
        hbox.addStretch()

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(self.monitor)

        self.setLayout(vbox)
コード例 #20
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'价差交易')

        # 创建组件
        tickMonitor = StTickMonitor(self.mainEngine, self.eventEngine)
        posMonitor = StPosMonitor(self.mainEngine, self.eventEngine)
        logMonitor = StLogMonitor(self.mainEngine, self.eventEngine)
        self.algoManager = StAlgoManager(self.stEngine)
        algoLogMonitor = StAlgoLogMonitor(self.mainEngine, self.eventEngine)

        # 创建按钮
        buttonInit = QtWidgets.QPushButton(u'初始化')
        buttonInit.clicked.connect(self.init)

        buttonStopAll = QtWidgets.QPushButton(u'全部停止')
        buttonStopAll.clicked.connect(self.algoManager.stopAll)

        # 创建集合
        groupTick = StGroup(tickMonitor, u'价差行情')
        groupPos = StGroup(posMonitor, u'价差持仓')
        groupLog = StGroup(logMonitor, u'日志信息')
        groupAlgo = StGroup(self.algoManager, u'价差算法')
        groupAlgoLog = StGroup(algoLogMonitor, u'算法信息')

        # 设置布局
        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(buttonInit)
        hbox.addStretch()
        hbox.addWidget(buttonStopAll)

        grid = QtWidgets.QGridLayout()
        grid.addLayout(hbox, 0, 0, 1, 2)
        grid.addWidget(groupTick, 1, 0)
        grid.addWidget(groupPos, 1, 1)
        grid.addWidget(groupAlgo, 2, 0, 1, 2)
        grid.addWidget(groupLog, 3, 0)
        grid.addWidget(groupAlgoLog, 3, 1)

        self.setLayout(grid)
コード例 #21
0
ファイル: uiAlgoWidget.py プロジェクト: pyctp/vnpurectp
 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)
コード例 #22
0
ファイル: uiSignalWidget.py プロジェクト: rehylas/myTrader
    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)
コード例 #23
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'RQData数据服务')
        self.setWindowIcon(QtGui.QIcon('vnpy.ico'))

        self.setFixedHeight(500)
        self.setFixedWidth(900)

        self.logMonitor = QtWidgets.QTextEdit()
        self.logMonitor.setReadOnly(True)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)

        self.signal.connect(self.updateLog)

        # 托盘配置
        self.tray = QtWidgets.QSystemTrayIcon()
        self.tray.setIcon(QtGui.QIcon('vnpy.ico'))
        self.tray.activated.connect(self.showManager)

        restoreAction = QtWidgets.QAction(u'还原', self, triggered=self.show)
        quitAction = QtWidgets.QAction(u'退出', self, triggered=self.exit)

        menu = QtWidgets.QMenu(QtWidgets.QApplication.desktop())
        menu.addAction(restoreAction)
        menu.addAction(quitAction)
        self.tray.setContextMenu(menu)

        self.tray.show()
コード例 #24
0
 def initUI(self):
     """"""
     self.setWindowTitle(u'日历管理')
     
     self.editor = CalendarEditor()
     
     buttonLoad = QtWidgets.QPushButton(u'读取日历')
     buttonSave = QtWidgets.QPushButton(u'保存日历')
     buttonInit = QtWidgets.QPushButton(u'初始化日历')
     buttonClear = QtWidgets.QPushButton(u'清空')
     
     buttonLoad.clicked.connect(self.editor.loadCalendar)
     buttonSave.clicked.connect(self.editor.saveCalendar)
     buttonInit.clicked.connect(self.editor.initCalendar)
     buttonClear.clicked.connect(self.editor.clearTable)
     
     hbox = QtWidgets.QHBoxLayout()
     hbox.addWidget(buttonLoad)
     hbox.addWidget(buttonSave)
     hbox.addWidget(buttonInit)
     hbox.addWidget(buttonClear)
     hbox.addStretch()
     
     vbox = QtWidgets.QVBoxLayout()
     vbox.addLayout(hbox)
     vbox.addWidget(self.editor)
     
     self.setLayout(vbox)
コード例 #25
0
 def addCell(self, name, row, col, color, alignment=None):
     """新增单元格"""
     cell = QtWidgets.QTableWidgetItem()
     self.setItem(row, col, cell)
     self.cellDict[name] = cell
     
     if color:
         cell.setForeground(QtGui.QColor(color))
     
     if alignment:
         cell.setTextAlignment(alignment)
     else:
         cell.setTextAlignment(QtCore.Qt.AlignCenter)
コード例 #26
0
ファイル: dmaAlgo.py プロジェクト: pyctp/vnpurectp
 def initAlgoLayout(self):
     """"""
     self.lineSymbol = QtWidgets.QLineEdit()
     
     self.comboDirection = QtWidgets.QComboBox()
     self.comboDirection.addItem(DIRECTION_LONG)
     self.comboDirection.addItem(DIRECTION_SHORT)
     self.comboDirection.setCurrentIndex(0)
     
     self.spinPrice = QtWidgets.QDoubleSpinBox()
     self.spinPrice.setMinimum(0)
     self.spinPrice.setMaximum(1000000000)
     self.spinPrice.setDecimals(8)
     
     self.spinVolume = QtWidgets.QDoubleSpinBox()
     self.spinVolume.setMinimum(0)
     self.spinVolume.setMaximum(1000000000)
     self.spinVolume.setDecimals(6)
     
     self.comboPriceType = QtWidgets.QComboBox()
     self.comboPriceType.addItems([PRICETYPE_LIMITPRICE, PRICETYPE_MARKETPRICE])
     self.comboPriceType.setCurrentIndex(0)
     
     self.comboOffset = QtWidgets.QComboBox()
     self.comboOffset.addItems(['', OFFSET_OPEN, OFFSET_CLOSE])
     self.comboOffset.setCurrentIndex(0)
     
     buttonStart = QtWidgets.QPushButton(u'启动')
     buttonStart.clicked.connect(self.addAlgo)
     buttonStart.setMinimumHeight(100)
     
     Label = QtWidgets.QLabel
     
     grid = QtWidgets.QGridLayout()
     grid.addWidget(Label(u'代码'), 0, 0)
     grid.addWidget(self.lineSymbol, 0, 1)
     grid.addWidget(Label(u'方向'), 1, 0)
     grid.addWidget(self.comboDirection, 1, 1)
     grid.addWidget(Label(u'价格'), 2, 0)
     grid.addWidget(self.spinPrice, 2, 1)
     grid.addWidget(Label(u'数量'), 3, 0)
     grid.addWidget(self.spinVolume, 3, 1)
     grid.addWidget(Label(u'类型'), 4, 0)
     grid.addWidget(self.comboPriceType, 4, 1)
     grid.addWidget(Label(u'开平'), 5, 0)
     grid.addWidget(self.comboOffset, 5, 1)
     
     return grid
コード例 #27
0
def runCalendarEditor():
    """运行日历编辑器"""
    reload(sys)
    sys.setdefaultencoding('utf8')
    
    app = QtWidgets.QApplication(sys.argv)
    app.setFont(QtGui.QFont(u'微软雅黑', 12))
    
    try:
        import qdarkstyle
        app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False))
    except:
        pass        
    
    manager = CalendarManager()
    manager.showMaximized()
    
    sys.exit(app.exec_())    
コード例 #28
0
    def initSignalLayout(self):
        """"""

        self.lineSymbol = QtWidgets.QLineEdit()

        self.comboDirection = QtWidgets.QComboBox()
        self.comboDirection.addItem(DIRECTION_LONG)
        self.comboDirection.addItem(DIRECTION_SHORT)
        self.comboDirection.setCurrentIndex(0)

        self.spinPotsize = QtWidgets.QDoubleSpinBox()
        self.spinPotsize.setMinimum(0)
        self.spinPotsize.setMaximum(1000)
        self.spinPotsize.setDecimals(0)

        self.spinFailval = QtWidgets.QDoubleSpinBox()
        self.spinFailval.setMinimum(0)
        self.spinFailval.setMaximum(1000)
        self.spinFailval.setDecimals(0)

        self.spinGoodval = QtWidgets.QDoubleSpinBox()
        self.spinGoodval.setMinimum(0)
        self.spinGoodval.setMaximum(1000)
        self.spinGoodval.setDecimals(0)

        buttonStart = QtWidgets.QPushButton(u'启动')
        buttonStart.clicked.connect(self.addSignal)
        buttonStart.setMinimumHeight(100)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'代码'), 0, 0)
        grid.addWidget(self.lineSymbol, 0, 1)

        grid.addWidget(Label(u'点大小'), 1, 0)
        grid.addWidget(self.spinPotsize, 1, 1)
        grid.addWidget(Label(u'亏点'), 2, 0)
        grid.addWidget(self.spinFailval, 2, 1)
        grid.addWidget(Label(u'盈点'), 3, 0)
        grid.addWidget(self.spinGoodval, 3, 1)

        return grid
コード例 #29
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)
コード例 #30
0
    def addMenuAction(self):
        """增加右键菜单内容"""
        refreshAction = QtWidgets.QAction(vtText.REFRESH, self)
        refreshAction.triggered.connect(self.refresh)

        self.menu.addAction(refreshAction)