コード例 #1
0
ファイル: widget.py プロジェクト: oness001/vnpy
    def init_ui(self):
        """"""
        self.setWindowTitle("K线图表")
        self.resize(1400, 800)
        self.chart = MarketDataChartWidget()

        self.contract_combo = QtWidgets.QComboBox()
        self.contracts = {
            c.vt_symbol: c
            for c in self.main_engine.get_all_contracts()
        }
        self.contract_combo.addItems(self.contracts.keys())
        self.contract_combo.setCurrentIndex(-1)
        self.contract_combo.currentTextChanged.connect(self.change_contract)

        self.interval_combo = QtWidgets.QComboBox()
        self.interval_combo.addItems([Interval.MINUTE.value])
        self.indicator_combo = QtWidgets.QComboBox()
        self.indicator_combo.addItems(
            [n for n in self.chart.indicators.keys()])
        self.indicator_combo.currentTextChanged.connect(
            self.chart.change_indicator)

        self.previous_btn = QtWidgets.QPushButton("←")
        self.previous_btn.released.connect(
            partial(self.update_previous_bar, 300))

        form = QtWidgets.QFormLayout()
        form.addRow("合约", self.contract_combo)
        form.addRow("周期", self.interval_combo)
        form.addRow("指标", self.indicator_combo)
        form.addRow(self.previous_btn)

        self.tick_info = InfoWidget()

        # Set layout
        box = QtWidgets.QHBoxLayout()
        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(form)
        vbox.addWidget(self.chart)

        infoBox = QtWidgets.QVBoxLayout()
        infoBox.addStretch(1)
        infoBox.addLayout(self.tick_info)
        infoBox.addStretch(5)

        box.addLayout(vbox)
        box.addLayout(infoBox)
        box.setStretchFactor(vbox, 8)
        box.setStretchFactor(infoBox, 1)

        self.setLayout(box)
コード例 #2
0
    def init_ui(self):
        """"""
        QLabel = QtWidgets.QLabel

        self.target_combo = QtWidgets.QComboBox()
        self.target_combo.addItems(list(self.DISPLAY_NAME_MAP.keys()))

        grid = QtWidgets.QGridLayout()
        grid.addWidget(QLabel("目标"), 0, 0)
        grid.addWidget(self.target_combo, 0, 1, 1, 3)
        grid.addWidget(QLabel("参数"), 1, 0)
        grid.addWidget(QLabel("开始"), 1, 1)
        grid.addWidget(QLabel("步进"), 1, 2)
        grid.addWidget(QLabel("结束"), 1, 3)

        # Add vt_symbol and name edit if add new strategy
        self.setWindowTitle(f"优化参数配置:{self.class_name}")

        validator = QtGui.QDoubleValidator()
        row = 2

        for name, value in self.parameters.items():
            type_ = type(value)
            if type_ not in [int, float]:
                continue

            start_edit = QtWidgets.QLineEdit(str(value))
            step_edit = QtWidgets.QLineEdit(str(1))
            end_edit = QtWidgets.QLineEdit(str(value))

            for edit in [start_edit, step_edit, end_edit]:
                edit.setValidator(validator)

            grid.addWidget(QLabel(name), row, 0)
            grid.addWidget(start_edit, row, 1)
            grid.addWidget(step_edit, row, 2)
            grid.addWidget(end_edit, row, 3)

            self.edits[name] = {
                "type": type_,
                "start": start_edit,
                "step": step_edit,
                "end": end_edit
            }

            row += 1

        parallel_button = QtWidgets.QPushButton("多进程优化")
        parallel_button.clicked.connect(self.generate_parallel_setting)
        grid.addWidget(parallel_button, row, 0, 1, 4)

        row += 1
        ga_button = QtWidgets.QPushButton("遗传算法优化")
        ga_button.clicked.connect(self.generate_ga_setting)
        grid.addWidget(ga_button, row, 0, 1, 4)

        self.setLayout(grid)
コード例 #3
0
    def init_ui(self):
        """"""
        self.setWindowTitle("策略K线图表")
        self.resize(1400, 800)

        # Create chart widget
        self.pnlChart = pg.PlotCurveItem()
        # Set layout
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(self.pnlChart)
        self.setLayout(vbox)
コード例 #4
0
    def __init__(self, start: datetime, end: datetime, parent=None):
        """"""
        super().__init__(parent)

        self.setWindowTitle("选择数据区间")

        self.start_edit = QtWidgets.QDateEdit(
            QtCore.QDate(start.year, start.month, start.day))
        self.end_edit = QtWidgets.QDateEdit(
            QtCore.QDate(end.year, end.month, end.day))

        button = QtWidgets.QPushButton("确定")
        button.clicked.connect(self.accept)

        form = QtWidgets.QFormLayout()
        form.addRow("开始时间", self.start_edit)
        form.addRow("结束时间", self.end_edit)
        form.addRow(button)

        self.setLayout(form)
コード例 #5
0
ファイル: widget.py プロジェクト: hjjwinner/VN_PY_PROJECT
    def init_ui(self):
        """"""
        self.setWindowTitle(self.title)
        self.resize(1100, 600)

        self.table = self.table_class(self.main_engine, self.event_engine)

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

        self.setLayout(vbox)
コード例 #6
0
ファイル: widget.py プロジェクト: ajmal017/jonpy
 def create_label(self,
                  color: str = "",
                  alignment: int = QtCore.Qt.AlignLeft) -> QtWidgets.QLabel:
     """
     Create label with certain font color.
     """
     label = QtWidgets.QLabel("-")
     if color:
         label.setStyleSheet(f"color:{color}")
     label.setAlignment(alignment)
     return label
コード例 #7
0
ファイル: widget.py プロジェクト: systemtrader/VnpyPro
    def create_job_07_save_etf_min(self):
        self.qCheckBoxJob07_save_etf_min = QtWidgets.QCheckBox(self)
        self.qCheckBoxJob07_save_etf_min.setText("JOB07 ETF分钟数据 📊")
        self.qProgressJob07_save_etf_min = QtWidgets.QProgressBar(self)
        self.qProgressJob07_save_etf_min.setMaximum(10000)  # 最小变动单位 0.01

        self.job07_save_etf_min = QA_GUI_DateFetch_SU_job07_etf_min()

        self.job07_save_etf_min.setLoggingUIWidget(self.logDisplay)
        self.job07_save_etf_min.setProgressUIWidget(
            self.qProgressJob07_save_etf_min)
        self.job07_save_etf_min.setCheckboxUIWidget(
            self.qCheckBoxJob07_save_etf_min)

        self.job07_save_etf_min.connectSignalSlot()

        self.qCheckboxWidgetList.append(self.qCheckBoxJob07_save_etf_min)
        self.qProgressWidgetList.append(self.qProgressJob07_save_etf_min)
        self.allSubJobList.append(self.job07_save_etf_min)
        self.taskListLayout.addWidget(self.qCheckBoxJob07_save_etf_min)
        self.taskListLayout.addWidget(self.qProgressJob07_save_etf_min)
コード例 #8
0
ファイル: widget.py プロジェクト: systemtrader/VnpyPro
    def create_job_10_save_stock_info(self):
        self.qCheckBoxJob10_save_stock_info = QtWidgets.QCheckBox(self)
        self.qCheckBoxJob10_save_stock_info.setText("JOB10 股票基本数据 📊")
        self.qProgressJob10_save_stock_info = QtWidgets.QProgressBar(self)
        self.qProgressJob10_save_stock_info.setMaximum(10000)  # 最小变动单位 0.01

        self.job10_save_stock_info = QA_GUI_DateFetch_SU_job10_stock_info()

        self.job10_save_stock_info.setLoggingUIWidget(self.logDisplay)
        self.job10_save_stock_info.setProgressUIWidget(
            self.qProgressJob10_save_stock_info)
        self.job10_save_stock_info.setCheckboxUIWidget(
            self.qCheckBoxJob10_save_stock_info)

        self.job10_save_stock_info.connectSignalSlot()

        self.qCheckboxWidgetList.append(self.qCheckBoxJob10_save_stock_info)
        self.qProgressWidgetList.append(self.qProgressJob10_save_stock_info)
        self.allSubJobList.append(self.job10_save_stock_info)
        self.taskListLayout.addWidget(self.qCheckBoxJob10_save_stock_info)
        self.taskListLayout.addWidget(self.qProgressJob10_save_stock_info)
コード例 #9
0
ファイル: widget.py プロジェクト: systemtrader/VnpyPro
    def create_job_02_save_stock_xdxr(self):
        self.qCheckBoxJob02_save_stock_xdxr = QtWidgets.QCheckBox(self)
        self.qCheckBoxJob02_save_stock_xdxr.setText("JOB02 除权除息数据 📊")
        self.qProgressJob02_save_stock_xdxr = QtWidgets.QProgressBar(self)
        self.qProgressJob02_save_stock_xdxr.setMaximum(100)

        self.job02_save_stock_xdxr = QA_GUI_DateFetch_SU_job02_stock_xdxr()

        self.job02_save_stock_xdxr.setLoggingUIWidget(self.logDisplay)
        self.job02_save_stock_xdxr.setProgressUIWidget(
            self.qProgressJob02_save_stock_xdxr)
        self.job02_save_stock_xdxr.setCheckboxUIWidget(
            self.qCheckBoxJob02_save_stock_xdxr)

        self.job02_save_stock_xdxr.connectSignalSlot()

        self.qCheckboxWidgetList.append(self.qCheckBoxJob02_save_stock_xdxr)
        self.qProgressWidgetList.append(self.qProgressJob02_save_stock_xdxr)
        self.allSubJobList.append(self.job02_save_stock_xdxr)
        self.taskListLayout.addWidget(self.qCheckBoxJob02_save_stock_xdxr)
        self.taskListLayout.addWidget(self.qProgressJob02_save_stock_xdxr)
コード例 #10
0
ファイル: widget.py プロジェクト: systemtrader/VnpyPro
    def create_job_04_save_index_day(self):
        self.qCheckBoxJob04_save_index_day = QtWidgets.QCheckBox(self)
        self.qCheckBoxJob04_save_index_day.setText("JOB04 指数日线数据 📊")
        self.qProgressJob04_save_index_day = QtWidgets.QProgressBar(self)
        self.qProgressJob04_save_index_day.setMaximum(10000)  # 最小变动单位 0.01

        self.job04_save_index_day = QA_GUI_DateFetch_SU_job04_index_day()

        self.job04_save_index_day.setLoggingUIWidget(self.logDisplay)
        self.job04_save_index_day.setProgressUIWidget(
            self.qProgressJob04_save_index_day)
        self.job04_save_index_day.setCheckboxUIWidget(
            self.qCheckBoxJob04_save_index_day)

        self.job04_save_index_day.connectSignalSlot()

        self.qCheckboxWidgetList.append(self.qCheckBoxJob04_save_index_day)
        self.qProgressWidgetList.append(self.qProgressJob04_save_index_day)
        self.allSubJobList.append(self.job04_save_index_day)
        self.taskListLayout.addWidget(self.qCheckBoxJob04_save_index_day)
        self.taskListLayout.addWidget(self.qProgressJob04_save_index_day)
コード例 #11
0
    def init_ui(self) -> None:
        """
        Init widget ui components.
        """
        self.setWindowTitle("Excel RTD")
        self.resize(600, 600)

        module_path = Path(__file__).parent.parent
        client_path = module_path.joinpath("vnpy_rtd.py")
        self.client_line = QtWidgets.QLineEdit(str(client_path))
        self.client_line.setReadOnly(True)

        copy_button = QtWidgets.QPushButton("复制")
        copy_button.clicked.connect(self.copy_client_path)

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

        self.port_label = QtWidgets.QLabel(
            "使用Socket端口:请求回应9001、广播推送9002"
        )

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.client_line)
        hbox.addWidget(copy_button)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(self.log_monitor)
        vbox.addWidget(self.port_label)
        self.setLayout(vbox)
コード例 #12
0
ファイル: widget.py プロジェクト: h1222443/vnpy
    def init_ui(self):
        """"""
        self.setFixedHeight(300)
        self.setFrameShape(self.Box)
        self.setLineWidth(1)

        self.init_button = QtWidgets.QPushButton("初始化")
        self.init_button.clicked.connect(self.init_strategy)

        self.start_button = QtWidgets.QPushButton("启动")
        self.start_button.clicked.connect(self.start_strategy)
        self.start_button.setEnabled(False)

        self.stop_button = QtWidgets.QPushButton("停止")
        self.stop_button.clicked.connect(self.stop_strategy)
        self.stop_button.setEnabled(False)

        self.edit_button = QtWidgets.QPushButton("编辑")
        self.edit_button.clicked.connect(self.edit_strategy)

        self.remove_button = QtWidgets.QPushButton("移除")
        self.remove_button.clicked.connect(self.remove_strategy)

        strategy_name = self._data["strategy_name"]
        vt_symbol = self._data["vt_symbol"]
        class_name = self._data["class_name"]
        author = self._data["author"]

        label_text = (
            f"{strategy_name}  -  {vt_symbol}  ({class_name} by {author})"
        )
        label = QtWidgets.QLabel(label_text)
        label.setAlignment(QtCore.Qt.AlignCenter)

        self.parameters_monitor = DataMonitor(self._data["parameters"])
        self.variables_monitor = DataMonitor(self._data["variables"])

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.init_button)
        hbox.addWidget(self.start_button)
        hbox.addWidget(self.stop_button)
        hbox.addWidget(self.edit_button)
        hbox.addWidget(self.remove_button)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(label)
        vbox.addLayout(hbox)
        vbox.addWidget(self.parameters_monitor)
        vbox.addWidget(self.variables_monitor)
        self.setLayout(vbox)
コード例 #13
0
    def init_ui(self) -> None:
        """"""
        self.setMinimumWidth(300)
        self.setWindowTitle(f"添加【{self.rule_name}】雷达信号")

        self.type_combo = QtWidgets.QComboBox()
        self.type_combo.addItems([
            SignalType.GREATER_THAN.value,
            SignalType.LESS_THAN.value,
            SignalType.EQUAL_TO.value,
        ])

        self.target_line = QtWidgets.QLineEdit()
        self.target_line.setValidator(QtGui.QDoubleValidator())

        self.sound_check = QtWidgets.QCheckBox()
        self.email_check = QtWidgets.QCheckBox()

        button = QtWidgets.QPushButton("添加")
        button.clicked.connect(self.add_signal)

        form = QtWidgets.QFormLayout()
        form.addRow("信号类型", self.type_combo)
        form.addRow("目标数值", self.target_line)
        form.addRow("声音通知", self.sound_check)
        form.addRow("邮件通知", self.email_check)
        form.addRow(button)

        self.setLayout(form)
コード例 #14
0
ファイル: widget.py プロジェクト: systemtrader/vnpy_mod
    def init_ui(self) -> None:
        """"""
        self.setWindowTitle("OptionMasterExt")

        self.portfolio_combo = QtWidgets.QComboBox()
        self.portfolio_combo.setFixedWidth(150)
        self.update_portfolio_combo()

        self.portfolio_button = QtWidgets.QPushButton("配置")
        self.portfolio_button.clicked.connect(self.open_portfolio_dialog)

        self.init_button = QtWidgets.QPushButton("初始化")
        self.init_button.clicked.connect(self.init_engine)

        self.volatility_button = QtWidgets.QPushButton("波动率交易")
        self.hedge_button = QtWidgets.QPushButton("Delta对冲")

        for button in [
            self.volatility_button,
            self.hedge_button,
        ]:
            button.setEnabled(False)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.portfolio_combo)
        hbox.addWidget(self.portfolio_button)
        hbox.addWidget(self.init_button)
        hbox.addWidget(self.volatility_button)
        hbox.addWidget(self.hedge_button)

        self.setLayout(hbox)
コード例 #15
0
ファイル: widget.py プロジェクト: systemtrader/vnpy_mod
    def init_ui(self):
        self.setWindowTitle("同步仓位")
        self.setMinimumWidth(300)

        # Select symbol widget
        self.sync_symbol_combo = ComboBox()
        self.sync_symbol_combo.pop_show.connect(self.refresh_symbol_list)
        self.sync_symbol_combo.activated[str].connect(self.set_sync_symbol)

        # Sync action button
        self.sync_open_button = QtWidgets.QPushButton("单合约开仓同步")
        self.sync_open_button.clicked.connect(self.sync_open)

        self.sync_close_button = QtWidgets.QPushButton("单合约平仓同步")
        self.sync_close_button.clicked.connect(self.sync_close)

        self.sync_button = QtWidgets.QPushButton("单合约开平同步")
        self.sync_button.clicked.connect(self.sync_open_and_close)

        self.sync_all_button = QtWidgets.QPushButton("所有持仓同步")
        self.sync_all_button.clicked.connect(self.sync_all)

        self.sync_net_button = QtWidgets.QPushButton("日内交易同步")
        self.sync_net_button.clicked.connect(lambda: self.sync_net_delta(is_sync_baisc=False))

        self.sync_basic_button = QtWidgets.QPushButton("日内底仓同步")
        self.sync_basic_button.clicked.connect(lambda: self.sync_net_delta(is_sync_baisc=True))

        for btn in [self.sync_open_button,
                    self.sync_close_button,
                    self.sync_button,
                    self.sync_all_button,
                    self.sync_net_button,
                    self.sync_basic_button]:
            btn.setFixedHeight(btn.sizeHint().height() * 1.5)

        # Set layout
        form_sync = QtWidgets.QFormLayout()
        form_sync.addRow("同步合约", self.sync_symbol_combo)
        form_sync.addRow(self.sync_open_button)
        form_sync.addRow(self.sync_close_button)
        form_sync.addRow(self.sync_button)
        form_sync.addRow(self.sync_all_button)
        form_sync.addRow(self.sync_net_button)
        form_sync.addRow(self.sync_basic_button)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(form_sync)

        self.setLayout(vbox)
コード例 #16
0
ファイル: widget.py プロジェクト: systemtrader/VnpyPro
    def create_job01_save_stock_week(self):
        self.qCheckBoxJob01_save_stock_week = QtWidgets.QCheckBox(self)
        self.qCheckBoxJob01_save_stock_week.setText("JOB01 周线数据 📊")
        self.qProgressJob01_save_stock_week = QtWidgets.QProgressBar(self)
        self.qProgressJob01_save_stock_week.setMaximum(100)

        # 🛠todo 不知道为何,QThread 继承的 都不执行 __init__
        self.job01_save_stock_week = QA_GUI_DateFetch_SU_job01_stock_week()

        self.job01_save_stock_week.setLoggingUIWidget(self.logDisplay)
        self.job01_save_stock_week.setProgressUIWidget(
            self.qProgressJob01_save_stock_week)
        self.job01_save_stock_week.setCheckboxUIWidget(
            self.qCheckBoxJob01_save_stock_week)

        self.job01_save_stock_week.connectSignalSlot()

        self.qCheckboxWidgetList.append(self.qCheckBoxJob01_save_stock_week)
        self.qProgressWidgetList.append(self.qProgressJob01_save_stock_week)
        self.allSubJobList.append(self.job01_save_stock_week)
        self.taskListLayout.addWidget(self.qCheckBoxJob01_save_stock_week)
        self.taskListLayout.addWidget(self.qProgressJob01_save_stock_week)
コード例 #17
0
    def init_ui(self):
        """"""
        self.setRowCount(len(self.KEY_NAME_MAP))
        self.setVerticalHeaderLabels(list(self.KEY_NAME_MAP.values()))

        self.setColumnCount(1)
        self.horizontalHeader().setVisible(False)
        self.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)

        for row, key in enumerate(self.KEY_NAME_MAP.keys()):
            cell = QtWidgets.QTableWidgetItem()
            self.setItem(row, 0, cell)
            self.cells[key] = cell
コード例 #18
0
    def init_ui(self):
        self.setWindowTitle("策略交易明细")
        self.resize(900, 600)

        self.dailyChart = DailyMonitor(self.main_engine, self.event_engine)
        self.tradeChart = TradeMonitor(self.main_engine, self.event_engine)
        self.cost_text = QtWidgets.QTextEdit()
        self.candleChart = CandleChartDialog(self.main_engine,
                                             self.event_engine)

        hsplit = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        vsplit = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        vsplit.addWidget(self.tradeChart)
        vsplit.addWidget(self.cost_text)
        vsplit.addWidget(self.candleChart)
        vsplit.setStretchFactor(0, 3)
        vsplit.setStretchFactor(1, 1)
        vsplit.setStretchFactor(2, 6)

        hsplit.addWidget(self.dailyChart)
        hsplit.addWidget(vsplit)
        hsplit.setStretchFactor(0, 4)
        hsplit.setStretchFactor(1, 6)
        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(hsplit)

        # hbox = QtWidgets.QHBoxLayout()
        # vbox = QtWidgets.QVBoxLayout()
        # vbox.addWidget(self.tradeChart, 8)
        # vbox.addWidget(self.cost_text, 2)
        # hbox.addWidget(self.dailyChart, 3)
        # hbox.addLayout(vbox, 7)
        self.setLayout(hbox)

        self.dailyChart.cellDoubleClicked.connect(self.update_daily_trades)
        # self.tradeChart.cellDoubleClicked.connect(self.show_candle_chart)
        self.tradeChart.cellClicked.connect(self.check_tradeid)
コード例 #19
0
    def init_ui(self):
        """"""
        self.setFixedHeight(300)
        self.setFrameShape(self.Box)
        self.setLineWidth(1)

        init_button = QtWidgets.QPushButton(" initialization ")
        init_button.clicked.connect(self.init_strategy)

        start_button = QtWidgets.QPushButton(" start up ")
        start_button.clicked.connect(self.start_strategy)

        stop_button = QtWidgets.QPushButton(" stop ")
        stop_button.clicked.connect(self.stop_strategy)

        edit_button = QtWidgets.QPushButton(" edit ")
        edit_button.clicked.connect(self.edit_strategy)

        remove_button = QtWidgets.QPushButton(" remove ")
        remove_button.clicked.connect(self.remove_strategy)

        strategy_name = self._data["strategy_name"]
        spread_name = self._data["spread_name"]
        class_name = self._data["class_name"]
        author = self._data["author"]

        label_text = (
            f"{strategy_name}  -  {spread_name}  ({class_name} by {author})")
        label = QtWidgets.QLabel(label_text)
        label.setAlignment(QtCore.Qt.AlignCenter)

        self.parameters_monitor = StrategyDataMonitor(self._data["parameters"])
        self.variables_monitor = StrategyDataMonitor(self._data["variables"])

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(init_button)
        hbox.addWidget(start_button)
        hbox.addWidget(stop_button)
        hbox.addWidget(edit_button)
        hbox.addWidget(remove_button)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(label)
        vbox.addLayout(hbox)
        vbox.addWidget(self.parameters_monitor)
        vbox.addWidget(self.variables_monitor)
        self.setLayout(vbox)
コード例 #20
0
ファイル: widget_jnpy.py プロジェクト: jojoquant/jonpy
    def init_ui(self):
        """"""
        form = QtWidgets.QFormLayout()

        for key, column_name_list in self.column_name_combo_dict.items():
            column_name_combo = QtWidgets.QComboBox()
            for column_name in column_name_list:
                column_name_combo.addItem(f'{column_name}', column_name)
            self.column_name_combo_dict[key] = column_name_combo
            form.addRow(key, column_name_combo)

        # Add vt_symbol and name edit if add new strategy
        self.setWindowTitle(f"技术指标参数配置:{self.class_name}")
        button_text = "确定"
        parameters = self.parameters

        for name, value in parameters.items():
            type_ = type(value)

            edit = QtWidgets.QLineEdit(str(value))
            if type_ is int:
                validator = QtGui.QIntValidator()
                edit.setValidator(validator)
            elif type_ is float:
                validator = QtGui.QDoubleValidator()
                edit.setValidator(validator)

            form.addRow(f"{name} {type_}", edit)

            self.edits[name] = (edit, type_)

        button = QtWidgets.QPushButton(button_text)
        button.clicked.connect(self.accept)
        form.addRow(button)

        self.setLayout(form)
コード例 #21
0
ファイル: widget.py プロジェクト: oness001/vnpy
    def init_ui(self):
        """"""
        self.setWindowTitle("交易风控")

        # Create widgets
        self.active_combo = QtWidgets.QComboBox()
        self.active_combo.addItems(["停止", "启动"])

        self.flow_limit_spin = RiskManagerSpinBox()
        self.flow_clear_spin = RiskManagerSpinBox()
        self.size_limit_spin = RiskManagerSpinBox()
        self.trade_limit_spin = RiskManagerSpinBox()
        self.active_limit_spin = RiskManagerSpinBox()
        self.cancel_limit_spin = RiskManagerSpinBox()
        self.position_limit_spin = RiskManagerSpinBox()

        save_button = QtWidgets.QPushButton("保存")
        save_button.clicked.connect(self.save_setting)

        # Form layout
        form = QtWidgets.QFormLayout()
        form.addRow("风控运行状态", self.active_combo)
        form.addRow("委托流控上限(笔)", self.flow_limit_spin)
        form.addRow("委托流控清空(秒)", self.flow_clear_spin)
        form.addRow("单笔委托上限(数量)", self.size_limit_spin)
        form.addRow("总成交上限(笔)", self.trade_limit_spin)
        form.addRow("活动委托上限(笔)", self.active_limit_spin)
        form.addRow("合约撤单上限(笔)", self.cancel_limit_spin)
        form.addRow("暴露头寸上限(手)", self.position_limit_spin)
        form.addRow(save_button)

        self.setLayout(form)

        # Set Fix Size
        hint = self.sizeHint()
        self.setFixedSize(hint.width() * 1.2, hint.height())
コード例 #22
0
ファイル: widget.py プロジェクト: sdywcd/vnpy-1
    def get_portfolio_item(self, reference: str) -> QtWidgets.QTreeWidgetItem:
        """"""
        portfolio_item = self.portfolio_items.get(reference, None)

        if not portfolio_item:
            portfolio_item = QtWidgets.QTreeWidgetItem()
            portfolio_item.setText(0, reference)
            for i in range(2, self.column_count):
                portfolio_item.setTextAlignment(i, QtCore.Qt.AlignCenter)

            self.portfolio_items[reference] = portfolio_item
            self.tree.addTopLevelItem(portfolio_item)

            self.reference_combo.addItem(reference)

        return portfolio_item
コード例 #23
0
    def init_ui(self):
        """"""
        self.setWindowTitle("RPC服务")
        self.setFixedWidth(900)
        self.setFixedHeight(500)

        self.start_button = QtWidgets.QPushButton("启动")
        self.start_button.clicked.connect(self.start_server)

        self.stop_button = QtWidgets.QPushButton("停止")
        self.stop_button.clicked.connect(self.stop_server)
        self.stop_button.setEnabled(False)

        for button in [self.start_button, self.stop_button]:
            hint = button.sizeHint()
            button.setFixedHeight(hint.height() * 2)
            button.setFixedWidth(hint.width() * 4)

        self.rep_line = QtWidgets.QLineEdit(self.rpc_engine.rep_address)
        self.rep_line.setFixedWidth(300)

        self.pub_line = QtWidgets.QLineEdit(self.rpc_engine.pub_address)
        self.pub_line.setFixedWidth(300)

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

        form = QtWidgets.QFormLayout()
        form.addRow("请求响应地址", self.rep_line)
        form.addRow("事件广播地址", self.pub_line)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(form)
        hbox.addWidget(self.start_button)
        hbox.addWidget(self.stop_button)
        hbox.addStretch()

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

        self.setLayout(vbox)
コード例 #24
0
ファイル: widget.py プロジェクト: sdywcd/vnpy-1
    def init_tree(self) -> None:
        """"""
        labels = [
            "数据",
            "本地代码",
            "代码",
            "交易所",
            "数据量",
            "开始时间",
            "结束时间",
            "",
            "",
            ""
        ]

        self.tree = QtWidgets.QTreeWidget()
        self.tree.setColumnCount(len(labels))
        self.tree.setHeaderLabels(labels)
コード例 #25
0
ファイル: widget.py プロジェクト: sdywcd/vnpy-1
    def get_contract_item(self, reference: str,
                          vt_symbol: str) -> QtWidgets.QTreeWidgetItem:
        """"""
        key = (reference, vt_symbol)
        contract_item = self.contract_items.get(key, None)

        if not contract_item:
            contract_item = QtWidgets.QTreeWidgetItem()
            contract_item.setText(1, vt_symbol)
            for i in range(2, self.column_count):
                contract_item.setTextAlignment(i, QtCore.Qt.AlignCenter)

            self.contract_items[key] = contract_item

            portfolio_item = self.get_portfolio_item(reference)
            portfolio_item.addChild(contract_item)

        return contract_item
コード例 #26
0
ファイル: widget.py プロジェクト: laoshu198838/vnpy_learning
 def init_ui(self):
     """"""
     self.setRowCount(len(self.KEY_NAME_MAP))
     self.setVerticalHeaderLabels(list(self.KEY_NAME_MAP.values()))
     # 设置表格除标题以外的列数,并让数字作为列名
     self.setColumnCount(1)
     # 设置数字列名不可见
     self.horizontalHeader().setVisible(False)
     # 自适应布局的大小
     self.horizontalHeader().setSectionResizeMode(
         QtWidgets.QHeaderView.Stretch
     )
     self.setEditTriggers(self.NoEditTriggers)
     # 每一行根据表名绑定一个Item
     for row, key in enumerate(self.KEY_NAME_MAP.keys()):
         cell = QtWidgets.QTableWidgetItem()
         self.setItem(row, 0, cell)
         self.cells[key] = cell
コード例 #27
0
ファイル: widget.py プロジェクト: systemtrader/vnpy_mod
    def init_ui(self):
        self.setWindowTitle("修改仓位")
        self.setMinimumWidth(300)

        self.symbol_combo = ComboBox()
        self.symbol_combo.pop_show.connect(self.refresh_symbol_list)
        self.symbol_combo.activated[str].connect(self.set_modify_symbol)

        validator = QtGui.QIntValidator()

        # self.long_pos_line = QtWidgets.QLineEdit()
        # self.long_pos_line.setValidator(validator)
        # self.short_pos_line = QtWidgets.QLineEdit()
        # self.short_pos_line.setValidator(validator)

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

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

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

        button_modify = QtWidgets.QPushButton("修改")
        button_modify.clicked.connect(self.modify)

        for btn in [button_modify]:
            btn.setFixedHeight(btn.sizeHint().height() * 1.5)

        form = QtWidgets.QFormLayout()
        form.addRow("合约代码", self.symbol_combo)
        # form.addRow("目标户多仓", self.long_pos_line)
        # form.addRow("目标户空仓", self.short_pos_line)
        form.addRow("底仓差", self.basic_delta_line)
        form.addRow("交易净仓", self.traded_net_line)
        form.addRow("丢失净仓", self.lost_follow_line)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(button_modify)

        vbox = QtWidgets.QVBoxLayout()
        vbox.addLayout(form)
        vbox.addLayout(hbox)

        self.setLayout(vbox)
コード例 #28
0
    def init_ui(self):
        """"""
        self.setWindowTitle("期权交易")

        self.symbol_line = QtWidgets.QLineEdit()

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

        self.price_line = QtWidgets.QLineEdit()
        self.price_line.setValidator(float_validator)

        int_validator = QtGui.QIntValidator()
        int_validator.setBottom(0)

        self.volume_line = QtWidgets.QLineEdit()
        self.volume_line.setValidator(int_validator)

        self.direction_combo = QtWidgets.QComboBox()
        self.direction_combo.addItems(
            [Direction.LONG.value, Direction.SHORT.value])

        self.offset_combo = QtWidgets.QComboBox()
        self.offset_combo.addItems([Offset.OPEN.value, Offset.CLOSE.value])

        order_button = QtWidgets.QPushButton("委托")
        order_button.clicked.connect(self.send_order)

        cancel_button = QtWidgets.QPushButton("全撤")
        cancel_button.clicked.connect(self.cancel_all)

        form = QtWidgets.QFormLayout()
        form.addRow("代码", self.symbol_line)
        form.addRow("方向", self.direction_combo)
        form.addRow("开平", self.offset_combo)
        form.addRow("价格", self.price_line)
        form.addRow("数量", self.volume_line)
        form.addRow(order_button)
        form.addRow(cancel_button)

        self.setLayout(form)
コード例 #29
0
    def init_ui(self):
        # 实例化列表视图
        title = QtWidgets.QTextEdit()
        title.setPlainText("已存策略")
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setReadOnly(True)
        title_box = QtWidgets.QVBoxLayout()
        title_box.addWidget(title)

        self.strategy_list_view = ListView()
        # 实例化列表模型,添加数据
        self.strategy_list_model = QtCore.QStringListModel()
        # item 单击事件
        self.strategy_list_view.clicked.connect(self.set_script_textarea)
        # item 双击事件
        self.strategy_list_view.doubleClicked.connect(
            self.double_clicked_event)
        # 取消双击触发器
        self.strategy_list_view.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        # 连接删除动作
        self.strategy_list_view.connect_delete_action(self.delete_action)
        # 连接重命名动作
        self.strategy_list_view.connect_rename_action(self.rename_action)

        # 初始化策略列表
        self.update_list()

        # 设置列表和内容窗口
        file_content = QtWidgets.QHBoxLayout()
        file_list_box = QtWidgets.QHBoxLayout()
        file_list_box.addWidget(self.strategy_list_view)
        self.script_textarea = QtWidgets.QTextEdit()
        self.script_textarea.setReadOnly(True)

        # 设置启动的初始值
        script_content = self.get_script_content(0)
        self.script_textarea.setPlainText(script_content)

        detail_box = QtWidgets.QHBoxLayout()
        detail_box.addWidget(self.script_textarea)

        file_content.addLayout(file_list_box)
        file_content.addLayout(detail_box)
        file_content.setStretch(0, 2)
        file_content.setStretch(1, 5)

        self.addLayout(title_box)
        self.addLayout(file_content)
        self.setStretch(0, 1)
        self.setStretch(1, 19)
コード例 #30
0
ファイル: widget.py プロジェクト: sdywcd/vnpy-1
    def init_table(self) -> None:
        """"""
        labels = [
            "时间",
            "开盘价",
            "最高价",
            "最低价",
            "收盘价",
            "成交量",
            "持仓量"
        ]

        self.table = QtWidgets.QTableWidget()
        self.table.setColumnCount(len(labels))
        self.table.setHorizontalHeaderLabels(labels)
        self.table.verticalHeader().setVisible(False)
        self.table.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.ResizeToContents
        )