コード例 #1
0
    def initAlgoLayout(self):
        """"""
        self.lineActiveVtSymbol = QtWidgets.QLineEdit()
        self.linePassiveVtSymbol = QtWidgets.QLineEdit()

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

        self.lineSpread = QtWidgets.QLineEdit()
        self.lineSpread.setValidator(validator)

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

        intValidator = QtGui.QIntValidator()
        intValidator.setBottom(10)
        self.lineInterval = QtWidgets.QLineEdit()
        self.lineInterval.setValidator(intValidator)

        Label = QtWidgets.QLabel

        grid = QtWidgets.QGridLayout()
        grid.addWidget(Label(u'主动腿代码'), 0, 0)
        grid.addWidget(self.lineActiveVtSymbol, 0, 1)
        grid.addWidget(Label(u'被动腿代码'), 1, 0)
        grid.addWidget(self.linePassiveVtSymbol, 1, 1)
        grid.addWidget(Label(u'套利价差'), 2, 0)
        grid.addWidget(self.lineSpread, 2, 1)
        grid.addWidget(Label(u'委托数量'), 3, 0)
        grid.addWidget(self.lineVolume, 3, 1)
        grid.addWidget(Label(u'运行间隔'), 4, 0)
        grid.addWidget(self.lineInterval, 4, 1)

        return grid
コード例 #2
0
 def setContent(self, text):
     """设置内容"""
     if text == DIRECTION_LONG or text == DIRECTION_NET:
         self.setForeground(QtGui.QColor('red'))
     elif text == DIRECTION_SHORT:
         self.setForeground(QtGui.QColor('green'))
     self.setText(text)
コード例 #3
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()
コード例 #4
0
    def initMenu(self):
        """初始化右键菜单"""
        self.menu = QtGui.QMenu(self)

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

        self.menu.addAction(saveAction)
コード例 #5
0
    def __init__(self, text=None, mainEngine=None):
        """Constructor"""
        super(AskCell, self).__init__()
        self.data = None

        self.setForeground(QtGui.QColor('black'))
        self.setBackground(QtGui.QColor(160, 255, 160))

        if text:
            self.setContent(text)
コード例 #6
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
コード例 #7
0
    def __init__(self, text=None, kind=None, data=None, key=None):
        """Constructor"""
        super(OmCellEditText, self).__init__()
        if data and key:
            self.key = key
            self.data = data

        if kind:
            if kind == "impv":
                self.setDecimals(2)
                self.setMinimum(0)
                self.setSingleStep(0.01)
                self.setMaximum(100)
            elif kind == 'volumn':
                self.setDecimals(0)
                self.setMinimum(0)
                self.setMaximum(1000)
            elif kind == 'decimals':
                self.setDecimals(0)
                self.setMinimum(-1000000)
                self.setMaximum(1000000)
        if text:
            self.setValue(float(text))

        self.setFixedWidth(200)
        self.setFont(QtGui.QFont("Roman times", 10))
コード例 #8
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(vtText.CONTRACT_SEARCH)

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

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

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

        self.setLayout(vbox)
コード例 #9
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
コード例 #10
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)
コード例 #11
0
ファイル: spreadAlgo.py プロジェクト: fswzb/vnpy20
    def initAlgoLayout(self):
        """"""
        self.lineStrategyName = QtWidgets.QLineEdit()
        self.lineVtSymbol = QtWidgets.QLineEdit()

        validator = QtGui.QDoubleValidator()
        validator.setBottom(0)
        intValidator = QtGui.QIntValidator()
        intValidator.setBottom(1)

        self.lineSpread = QtWidgets.QLineEdit()
        self.lineSpread.setValidator(validator)

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

        self.lineTradeCommand = QtWidgets.QLineEdit()

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

        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.lineTradeCommand, 1, 1)
        grid.addWidget(Label(u'套利价差'), 2, 0)
        grid.addWidget(self.lineSpread, 2, 1)
        grid.addWidget(Label(u'委托数量'), 3, 0)
        grid.addWidget(self.lineVolume, 3, 1)
        grid.addWidget(Label(u'运行间隔'), 4, 0)
        grid.addWidget(self.lineInterval, 4, 1)
        grid.addWidget(Label(u'策略名称'), 5, 0)
        grid.addWidget(self.lineStrategyName, 5, 1)

        return grid
コード例 #12
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_())    
コード例 #13
0
    def __init__(self,
                 text=None,
                 background=None,
                 foreground=None,
                 data=None,
                 fontSize=None):
        """Constructor"""
        super(OmCell, self).__init__()
        self.data = data
        self.background = None

        if text:
            self.setText(text)
        if foreground:
            self.setForeground(foreground)

        if background:
            self.setBackground(background)
            self.background = background
        if fontSize:
            self.setFont(QtGui.QFont("Roman times", fontSize))

        self.setTextAlignment(QtCore.Qt.AlignCenter)
コード例 #14
0
import os
import platform
from collections import OrderedDict

from six import text_type

from vnpy.event import *
from vnpy.trader import vtText
from vnpy.trader.vtEvent import *
from vnpy.trader.vtConstant import *
from vnpy.trader.vtFunction import *
from vnpy.trader.vtGateway import *
from vnpy.trader.uiQt import QtGui, QtWidgets, QtCore, BASIC_FONT


COLOR_RED = QtGui.QColor('red')
COLOR_GREEN = QtGui.QColor('green')
COLOR_YELLOW = QtGui.QColor('yellow')


########################################################################
class BasicCell(QtWidgets.QTableWidgetItem):
    """基础的单元格"""

    #----------------------------------------------------------------------
    def __init__(self, text=None, mainEngine=None):
        """Constructor"""
        super(BasicCell, self).__init__()
        self.data = None
        
        self.setTextAlignment(QtCore.Qt.AlignCenter)
コード例 #15
0
# encoding: UTF-8

import json
import csv
import os
import platform
from collections import OrderedDict

from vnpy.event import *
from vnpy.trader.vtEvent import *
from vnpy.trader.vtFunction import *
from vnpy.trader.vtGateway import *
from vnpy.trader import vtText
from vnpy.trader.uiQt import QtGui, QtWidgets, QtCore, BASIC_FONT

COLOR_RED = QtGui.QColor('red')
COLOR_GREEN = QtGui.QColor('green')


########################################################################
class BasicCell(QtWidgets.QTableWidgetItem):
    """基础的单元格"""

    #----------------------------------------------------------------------
    def __init__(self, text=None, mainEngine=None):
        """Constructor"""
        super(BasicCell, self).__init__()
        self.data = None
        if text:
            self.setContent(text)
コード例 #16
0
    def addMenuAction(self):
        """增加右键菜单内容"""
        refreshAction = QtGui.QAction(vtText.REFRESH, self)
        refreshAction.triggered.connect(self.refresh)

        self.menu.addAction(refreshAction)
コード例 #17
0
        self.show()

    #----------------------------------------------------------------------
    def closeEvent(self, event):
        """"""
        self.hide()
        event.ignore()

    #----------------------------------------------------------------------
    def exit(self):
        """"""
        self.active = False
        self.thread.join()

        QtWidgets.qApp.quit()


if __name__ == '__main__':
    font = QtGui.QFont(u'微软雅黑', 12)

    app = QtWidgets.QApplication([])
    app.setFont(font)
    app.setStyleSheet(qdarkstyle.load_stylesheet_from_environment())

    ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
        'RQDataService')

    manager = RqDataManager()
    manager.show()

    app.exec_()
コード例 #18
0
ファイル: uiTcWidget.py プロジェクト: pyctp/vnpurectp
 def initUi(self):
     """"""
     self.setWindowTitle(u'交易复制')
     self.setMinimumWidth(700)
     self.setMinimumHeight(700)
     
     # 创建组件
     self.lineReqAddress = QtWidgets.QLineEdit(self.REQ_ADDRESS)
     self.lineSubAddress= QtWidgets.QLineEdit(self.SUB_ADDRESS)
     self.lineRepAddress = QtWidgets.QLineEdit(self.REP_ADDRESS)
     self.linePubAddress = QtWidgets.QLineEdit(self.PUB_ADDRESS)
     
     validator = QtGui.QDoubleValidator()
     validator.setBottom(0)
     self.lineCopyRatio = QtWidgets.QLineEdit()
     self.lineCopyRatio.setValidator(validator)
     self.lineCopyRatio.setText(self.COPY_RATIO)
     
     validator2 = QtGui.QIntValidator()
     validator2.setBottom(1)
     self.lineInterval = QtWidgets.QLineEdit()
     self.lineInterval.setValidator(validator2)
     self.lineInterval.setText(self.INTERVAL)
     
     self.buttonProvider = QtWidgets.QPushButton(u'启动发布者')
     self.buttonProvider.clicked.connect(self.startProvider)
     
     self.buttonSubscriber = QtWidgets.QPushButton(u'启动订阅者')
     self.buttonSubscriber.clicked.connect(self.startSubscriber)
     
     self.buttonStopEngine = QtWidgets.QPushButton(u'停止')
     self.buttonStopEngine.clicked.connect(self.stopEngine)
     self.buttonStopEngine.setEnabled(False)
     
     self.buttonResetAddress = QtWidgets.QPushButton(u'重置地址')
     self.buttonResetAddress.clicked.connect(self.resetAddress)
     
     self.logMonitor = QtWidgets.QTextEdit()
     self.logMonitor.setReadOnly(True)
     
     self.widgetList = [
         self.lineCopyRatio,
         self.lineInterval,
         self.linePubAddress,
         self.lineSubAddress,
         self.lineRepAddress,
         self.lineReqAddress,
         self.buttonProvider,
         self.buttonSubscriber,
         self.buttonResetAddress
     ]
     
     # 布局
     QLabel = QtWidgets.QLabel
     grid = QtWidgets.QGridLayout()
     
     grid.addWidget(QLabel(u'响应地址'), 0, 0)
     grid.addWidget(self.lineRepAddress, 0, 1)
     grid.addWidget(QLabel(u'请求地址'), 0, 2)
     grid.addWidget(self.lineReqAddress, 0, 3)
     
     grid.addWidget(QLabel(u'发布地址'), 1, 0)
     grid.addWidget(self.linePubAddress, 1, 1)
     grid.addWidget(QLabel(u'订阅地址'), 1, 2)
     grid.addWidget(self.lineSubAddress, 1, 3)
     
     grid.addWidget(QLabel(u'发布间隔(秒)'), 2, 0)
     grid.addWidget(self.lineInterval, 2, 1)
     grid.addWidget(QLabel(u'复制比例(倍)'), 2, 2)
     grid.addWidget(self.lineCopyRatio, 2, 3)
     
     grid.addWidget(self.buttonProvider, 3, 0, 1, 2)
     grid.addWidget(self.buttonSubscriber, 3, 2, 1, 2)
     grid.addWidget(self.buttonStopEngine, 4, 0, 1, 2)
     grid.addWidget(self.buttonResetAddress, 4, 2, 1, 2)
     
     grid.addWidget(self.logMonitor, 5, 0, 1, 4)
     
     self.setLayout(grid)
コード例 #19
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)
コード例 #20
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(vtText.TRADING)
        self.setMaximumWidth(400)
        self.setFrameShape(self.Box)  # 设置边框
        self.setLineWidth(1)

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

        self.lineSymbol = QtGui.QLineEdit()
        self.lineName = QtGui.QLineEdit()

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

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

        self.spinPrice = QtGui.QDoubleSpinBox()
        self.spinPrice.setDecimals(4)
        self.spinPrice.setMinimum(-10000)  # 原来是0,为支持套利,改为-10000
        self.spinPrice.setMaximum(100000)

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

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

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

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

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

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

        #self.lineOrder = QtGui.QLineEdit()

        gridleft = QtGui.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 = QtGui.QLabel(vtText.BID_1)
        labelBid2 = QtGui.QLabel(vtText.BID_2)
        labelBid3 = QtGui.QLabel(vtText.BID_3)
        labelBid4 = QtGui.QLabel(vtText.BID_4)
        labelBid5 = QtGui.QLabel(vtText.BID_5)

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

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

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

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

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

        gridRight = QtGui.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 = QtGui.QPushButton(vtText.SEND_ORDER)
        buttonCancelAll = QtGui.QPushButton(vtText.CANCEL_ALL)

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

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

        vbox = QtGui.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)
コード例 #21
0
 def __init__(self, text=None, mainEngine=None):
     """Constructor"""
     super(BidCell, self).__init__(text)
     
     self.setForeground(QtGui.QColor('black'))
     self.setBackground(QtGui.QColor(255,174,201))
コード例 #22
0
# encoding: UTF-8

from vnpy.trader.uiQt import QtGui, QtWidgets, QtCore

COLOR_BID = QtGui.QColor(255, 174, 201)
COLOR_ASK = QtGui.QColor(160, 255, 160)
COLOR_STRIKE = QtGui.QColor(0, 0, 160)
COLOR_POS = QtGui.QColor(225, 255, 255)
COLOR_SYMBOL = QtGui.QColor('white')
COLOR_BLACK = QtGui.QColor('black')

#波动率的计算方式comprehensive:每个月的利率一样,采用平值期权上下两档,五档数据计算,Separate:每个合约都有独立的利率分开算
VOLATILITY_RULE_COMPREHENSIVE = "comprehensive"
VOLATILITY_RULE_SEPARATE = "Separate"

CALL_SUFFIX = '_call'
PUT_SUFFIX = '_put'

STYLESHEET_START = "background-color: rgb(111,255,244); color: black"
STYLESHEET_STOP = "background-color: rgb(255,201,111); color: black"


########################################################################
class OmCell(QtWidgets.QTableWidgetItem):
    """单元格"""

    #----------------------------------------------------------------------
    def __init__(self,
                 text=None,
                 background=None,
                 foreground=None,