From e44943f3cc6a1b36ee38be4c173b813c80915adb Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 13 Nov 2019 23:49:11 +0800 Subject: [PATCH] [Add] remove strategy rows from monitor --- vnpy/app/portfolio_manager/ui/widget.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vnpy/app/portfolio_manager/ui/widget.py b/vnpy/app/portfolio_manager/ui/widget.py index 0126247c..77b70ae4 100644 --- a/vnpy/app/portfolio_manager/ui/widget.py +++ b/vnpy/app/portfolio_manager/ui/widget.py @@ -45,6 +45,7 @@ class PortfolioManager(QtWidgets.QWidget): self.management_widget = StrategyManagementWidget( self.portfolio_engine, self.trading_widget, + strategy_monitor ) vbox = QtWidgets.QVBoxLayout() @@ -97,6 +98,15 @@ class PortfolioStrategyMonitor(BaseMonitor): "create_time": {"display": "创建时间", "cell": BaseCell, "update": False}, } + def remove_strategy(self, name: str): + """""" + if name not in self.cells: + return + + row_cells = self.cells.pop(name) + row = self.row(row_cells["net_pos"]) + self.removeRow(row) + class PortfolioTradeMonitor(BaseMonitor): """ @@ -269,13 +279,15 @@ class StrategyManagementWidget(QtWidgets.QWidget): def __init__( self, portfolio_engine: PortfolioEngine, - trading_widget: StrategyTradingWidget + trading_widget: StrategyTradingWidget, + strategy_monitor: PortfolioStrategyMonitor ): """""" super().__init__() self.portfolio_engine = portfolio_engine self.trading_widget = trading_widget + self.strategy_monitor = strategy_monitor self.init_ui() self.update_combo() @@ -361,6 +373,8 @@ class StrategyManagementWidget(QtWidgets.QWidget): ) self.update_combo() + + self.strategy_monitor.remove_strategy(name) else: QtWidgets.QMessageBox.warning( self,