示例#1
0
    def initUi(self):
        """初始化界面"""
        self.setTitle(self.name)

        paramLabel = QtGui.QLabel(u'参数')
        varLabel = QtGui.QLabel(u'变量')

        self.paramMonitor = ValueMonitor(self)
        self.varMonitor = ValueMonitor(self)

        buttonStart = QtGui.QPushButton(u'启动')
        buttonStop = QtGui.QPushButton(u'停止')
        buttonStart.clicked.connect(self.start)
        buttonStop.clicked.connect(self.stop)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(buttonStart)
        hbox.addWidget(buttonStop)
        hbox.addStretch()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(paramLabel)
        vbox.addWidget(self.paramMonitor)
        vbox.addWidget(varLabel)
        vbox.addWidget(self.varMonitor)
        self.setLayout(vbox)
示例#2
0
    def __init__(self, analysisEngine):  # 初始化方法
        QtGui.QWidget.__init__(self)  # 调用父类初始化方法
        self.setWindowTitle('NetCurve')  # 设置窗口标题
        self.path = os.getcwd() + '/ctaLogFile/ctaPosFile'
        # self.path = os.getcwd() + '/statement/netSource'
        self.analysisEngine = analysisEngine
        #        self.resize(300,200)        # 设置窗口大小
        gridlayout = QtGui.QGridLayout()  # 创建布局组件

        self.cbAccount = QtGui.QComboBox()
        self.cbContract = QtGui.QComboBox()
        self.buttonStart = QtGui.QPushButton()
        self.lineedit = QtGui.QLineEdit('1000000')

        self.labelAcct = QtGui.QLabel(u'账户')
        self.labelCon = QtGui.QLabel(u'标的')
        self.labelAmount = QtGui.QLabel(u'初始金额')
        self.labelEvaluate = QtGui.QLabel()

        tree = lambda: collections.defaultdict(tree)
        self.dataList = tree()
        self.fileName = []

        self.loadAllPosFile()
        self.cbAccount.addItems(
            [k for k in self.groupByPosFile('name').keys()])
        self.cbContract.addItems(
            [k for k in self.groupByPosFile('contract').keys()])
示例#3
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(text.DATA_RECORDER)

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

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

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

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

        # 设置布局
        grid = QtGui.QGridLayout()

        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
示例#4
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'行情数据记录工具')

        # 记录合约配置监控
        tickLabel = QtGui.QLabel(u'Tick记录')
        self.tickTable = QtGui.QTableWidget()
        self.tickTable.setColumnCount(2)
        self.tickTable.verticalHeader().setVisible(False)
        self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.tickTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.tickTable.setAlternatingRowColors(True)
        self.tickTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        barLabel = QtGui.QLabel(u'Bar记录')
        self.barTable = QtGui.QTableWidget()
        self.barTable.setColumnCount(2)
        self.barTable.verticalHeader().setVisible(False)
        self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.barTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.barTable.setAlternatingRowColors(True)
        self.barTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        activeLabel = QtGui.QLabel(u'主力合约')
        self.activeTable = QtGui.QTableWidget()
        self.activeTable.setColumnCount(2)
        self.activeTable.verticalHeader().setVisible(False)
        self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.activeTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.activeTable.setAlternatingRowColors(True)
        self.activeTable.setHorizontalHeaderLabels([u'主力代码', u'合约代码'])

        # 日志监控
        self.logMonitor = QtGui.QTextEdit()
        self.logMonitor.setReadOnly(True)
        self.logMonitor.setMinimumHeight(300)

        # 设置布局
        grid = QtGui.QGridLayout()

        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addWidget(self.logMonitor)
        self.setLayout(vbox)
示例#5
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'登录')

        # 设置界面
        self.userName = QtGui.QLineEdit()
        self.password = QtGui.QTextEdit()
        self.comboStrategy = QtGui.QComboBox()

        grid = QtGui.QGridLayout()
        grid.addWidget(LoginLine(), 1, 0, 1, 2)
        grid.addWidget(QtGui.QLabel(u'用户名'), 2, 0)
        grid.addWidget(self.userName, 2, 1)
        grid.addWidget(QtGui.QLabel(u'令牌'), 3, 0)
        grid.addWidget(self.password, 3, 1)
        grid.addWidget(LoginLine(), 4, 0, 1, 2)
        grid.addWidget(QtGui.QLabel(u'策略'), 5, 0)
        grid.addWidget(self.comboStrategy, 5, 1)
        grid.addWidget(LoginLine(), 6, 0, 1, 2)

        self.buttonCancel = QtGui.QPushButton(u'取消')
        self.buttonConfirm = QtGui.QPushButton(u'确认')
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.buttonConfirm)
        hbox.addWidget(self.buttonCancel)
        self.buttonConfirm.setDefault(True)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        # 设为固定大小
        self.setFixedSize(self.sizeHint())

        self.buttonCancel.clicked.connect(self.close)
        self.buttonConfirm.clicked.connect(self.login)
        self.userName.returnPressed.connect(self.password.setFocus)

        # init username & token
        username = self.setting['username']
        token = self.setting['token']

        self.userName.setText(username)
        self.password.setText(token)
示例#6
0
    def initUi(self):
        """"""
        QtGui.QWidget.__init__(self)         # 调用父类初始化方法
        self.setWindowTitle(u'设置参数')
        self.resize(300,400)                 # 设置窗口大小
        gridlayout = QtGui.QGridLayout()     # 创建布局组件
        i = 0
        lName  = QtGui.QLabel(u'参数')
        lValue = QtGui.QLabel(u'数值')
        gridlayout.addWidget(lName,  i, 0 )
        gridlayout.addWidget(lValue, i, 1 )
        for name in self.paramDict:
            i += 1
            label = QtGui.QLabel(name)                              # 创建单选框
            self.valueEdit[name] = QtGui.QLineEdit()
            self.valueEdit[name].setText(str(self.paramDict[name]))
            self.valueEdit[name].setFocusPolicy(QtCore.Qt.NoFocus)
            gridlayout.addWidget(label, i, 0 )                      # 添加文本
            gridlayout.addWidget(self.valueEdit[name], i,  1)       # 添加文本框

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(gridlayout)
        self.addButton(vbox)
        self.setLayout(vbox)                                    
示例#7
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(u'行情数据记录工具')

        # 菜单
        lineSelect = QtGui.QLabel(u'需要收集的合约:')
        buttonSelect = QtGui.QPushButton(u'选择')

        lineType = QtGui.QLabel(u'合成Bar类型:')
        barType = ['1m', '5m', '15m', '30m', '60m']
        comboType = QtGui.QComboBox()
        comboType.addItems(barType)

        lineStart = QtGui.QLabel(u'开始收集:')
        buttonStart = QtGui.QPushButton(u'收集')

        buttonSelect.clicked.connect(self.select)
        buttonStart.clicked.connect(self.start)

        # 记录合约配置监控
        tickLabel = QtGui.QLabel(u'Tick记录')
        self.tickTable = QtGui.QTableWidget()
        self.tickTable.setColumnCount(2)
        self.tickTable.verticalHeader().setVisible(False)
        self.tickTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.tickTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.tickTable.setAlternatingRowColors(True)
        self.tickTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        barLabel = QtGui.QLabel(u'Bar记录')
        self.barTable = QtGui.QTableWidget()
        self.barTable.setColumnCount(2)
        self.barTable.verticalHeader().setVisible(False)
        self.barTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.barTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.barTable.setAlternatingRowColors(True)
        self.barTable.setHorizontalHeaderLabels([u'合约代码', u'接口'])

        activeLabel = QtGui.QLabel(u'主力合约')
        self.activeTable = QtGui.QTableWidget()
        self.activeTable.setColumnCount(2)
        self.activeTable.verticalHeader().setVisible(False)
        self.activeTable.setEditTriggers(QtGui.QTableWidget.NoEditTriggers)
        self.activeTable.horizontalHeader().setResizeMode(
            QtGui.QHeaderView.Stretch)
        self.activeTable.setAlternatingRowColors(True)
        self.activeTable.setHorizontalHeaderLabels([u'主力代码', u'合约代码'])

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

        self.logMonitor2 = QtGui.QTextEdit()
        self.logMonitor2.setReadOnly(True)
        self.logMonitor2.setMinimumHeight(600)

        self.logMonitor3 = QtGui.QTextEdit()
        self.logMonitor3.setReadOnly(True)
        self.logMonitor3.setMinimumHeight(600)

        # 设置布局
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(lineSelect)
        hbox.addWidget(buttonSelect)
        hbox.addWidget(lineType)
        hbox.addWidget(comboType)
        hbox.addWidget(lineStart)
        hbox.addWidget(buttonStart)

        grid = QtGui.QGridLayout()
        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        grid2 = QtGui.QGridLayout()
        grid2.addWidget(self.logMonitor, 0, 0)
        grid2.addWidget(self.logMonitor2, 0, 1)
        grid2.addWidget(self.logMonitor3, 0, 2)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addLayout(grid)
        vbox.addLayout(grid2)
        self.setLayout(vbox)
示例#8
0
    def initLabel(self):
        if self.name == "":
            strategyname_label = QtGui.QLabel(u"策略名", self)
            strategyname_label.setGeometry(QtCore.QRect(25, 25, 70, 22))
            self.strategyname_label = QtGui.QLineEdit(self)
            self.strategyname_label.setGeometry(QtCore.QRect(120, 25, 70, 22))

        self.closeFirst = QtGui.QCheckBox(u'平仓优先', self)
        self.closeFirst.setGeometry(QtCore.QRect(210, 25, 90, 22))

        label_symbol = QtGui.QLabel(u"合约", self)
        label_symbol.setGeometry(QtCore.QRect(25, 50, 70, 22))
        self.lineEdit_label_symbol = QtGui.QLineEdit(self)
        self.lineEdit_label_symbol.setGeometry(QtCore.QRect(120, 50, 70, 22))

        symbolDirection = QtGui.QLabel(u"方向", self)
        symbolDirection.setGeometry(QtCore.QRect(210, 50, 70, 22))
        self.directionCombo = QtGui.QComboBox(self)
        self.directionCombo.addItem("")
        self.directionCombo.addItem("long")
        self.directionCombo.addItem('short')
        self.directionCombo.setGeometry(QtCore.QRect(245, 50, 50, 22))

        label_longBuyUnit = QtGui.QLabel(u"每笔数量", self)
        label_longBuyUnit.setGeometry(QtCore.QRect(25, 75, 50, 22))
        self.lineEdit_label_longBuyUnit = QtGui.QLineEdit(self)
        self.lineEdit_label_longBuyUnit.setGeometry(
            QtCore.QRect(120, 75, 70, 22))

        maxStpLos = QtGui.QLabel(u'止损', self)
        maxStpLos.setGeometry(QtCore.QRect(210, 75, 70, 22))
        self.lineEdit_label_maxStpLos = QtGui.QLineEdit(self)
        self.lineEdit_label_maxStpLos.setGeometry(QtCore.QRect(
            245, 75, 60, 22))

        label_longPriceCoe = QtGui.QLabel(u"价格系数", self)
        label_longPriceCoe.setGeometry(QtCore.QRect(25, 100, 50, 22))
        self.lineEdit_label_longPriceCoe = QtGui.QLineEdit(self)
        self.lineEdit_label_longPriceCoe.setGeometry(
            QtCore.QRect(120, 100, 70, 22))

        label_longPosition = QtGui.QLabel(u"当前持仓量", self)
        label_longPosition.setGeometry(QtCore.QRect(25, 125, 50, 22))
        self.lineEdit_label_longPosition = QtGui.QLineEdit(self)
        self.lineEdit_label_longPosition.setGeometry(
            QtCore.QRect(120, 125, 70, 22))

        label_stpProfit = QtGui.QLabel(u"止赢", self)
        label_stpProfit.setGeometry(QtCore.QRect(25, 150, 50, 22))
        self.lineEdit_label_stpProfit = QtGui.QLineEdit(self)
        self.lineEdit_label_stpProfit.setGeometry(
            QtCore.QRect(120, 150, 70, 22))

        label_slippage = QtGui.QLabel(u"滑点", self)
        label_slippage.setGeometry(QtCore.QRect(25, 175, 50, 22))
        self.lineEdit_label_slippage = QtGui.QLineEdit(self)
        self.lineEdit_label_slippage.setGeometry(QtCore.QRect(
            120, 175, 70, 22))

        label_mail = QtGui.QLabel(u"邮箱", self)
        label_mail.setGeometry(QtCore.QRect(25, 200, 50, 22))
        self.lineEdit_label_mail = QtGui.QLineEdit(self)
        self.lineEdit_label_mail.setGeometry(QtCore.QRect(120, 200, 200, 22))

        label_buyPrice = QtGui.QLabel(u"开仓价差", self)
        label_buyPrice.setGeometry(QtCore.QRect(25, 225, 50, 22))
        self.lineEdit_label_buyPrice = QtGui.QLineEdit(self)
        self.lineEdit_label_buyPrice.setGeometry(
            QtCore.QRect(120, 225, 200, 22))

        label_stoptime = QtGui.QLabel(u"停止时间", self)
        label_stoptime.setGeometry(QtCore.QRect(25, 250, 50, 22))
        self.lineEdit_label_stoptime = QtGui.QLineEdit(self)
        self.lineEdit_label_stoptime.setGeometry(
            QtCore.QRect(120, 250, 200, 22))

        self.isFilter = QtGui.QCheckBox(u'当波动大于', self)
        self.isFilter.setGeometry(QtCore.QRect(25, 275, 150, 22))
        self.lineEdit_label_var = QtGui.QLineEdit(self)
        self.lineEdit_label_var.setGeometry(QtCore.QRect(120, 275, 20, 22))
        label_pct = QtGui.QLabel(u'% 时忽略', self)
        label_pct.setGeometry(QtCore.QRect(141, 275, 80, 22))
示例#9
0
    def initUi(self):
        """初始化界面"""
        self.setWindowTitle(text.DATA_RECORDER)

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

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

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

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

        # 设置布局
        grid = QtGui.QGridLayout()

        grid.addWidget(tickLabel, 0, 0)
        grid.addWidget(barLabel, 0, 1)
        grid.addWidget(activeLabel, 0, 2)
        grid.addWidget(self.tickTable, 1, 0)
        grid.addWidget(self.barTable, 1, 1)
        grid.addWidget(self.activeTable, 1, 2)

        # 原有的布局结构 -> 备份
        # vbox = QtGui.QVBoxLayout()
        # vbox.addLayout(grid)
        # vbox.addWidget(self.logMonitor)
        # self.setLayout(vbox)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(grid)
        # 在底部增加的一个可切换组件,有价格图和行情两个界面
        bottomWidget = QtGui.QTabWidget()
        priceWidget = PriceWidget(self.eventEngine, self.drEngine)
        bottomWidget.addTab(priceWidget, u'Price')
        bottomWidget.addTab(self.logMonitor, u'行情')
        vbox.addWidget(bottomWidget)
        self.setLayout(vbox)