[Add] remove strategy rows from monitor

This commit is contained in:
vn.py 2019-11-13 23:49:11 +08:00
parent e7052df3b0
commit e44943f3cc

View File

@ -45,6 +45,7 @@ class PortfolioManager(QtWidgets.QWidget):
self.management_widget = StrategyManagementWidget( self.management_widget = StrategyManagementWidget(
self.portfolio_engine, self.portfolio_engine,
self.trading_widget, self.trading_widget,
strategy_monitor
) )
vbox = QtWidgets.QVBoxLayout() vbox = QtWidgets.QVBoxLayout()
@ -97,6 +98,15 @@ class PortfolioStrategyMonitor(BaseMonitor):
"create_time": {"display": "创建时间", "cell": BaseCell, "update": False}, "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): class PortfolioTradeMonitor(BaseMonitor):
""" """
@ -269,13 +279,15 @@ class StrategyManagementWidget(QtWidgets.QWidget):
def __init__( def __init__(
self, self,
portfolio_engine: PortfolioEngine, portfolio_engine: PortfolioEngine,
trading_widget: StrategyTradingWidget trading_widget: StrategyTradingWidget,
strategy_monitor: PortfolioStrategyMonitor
): ):
"""""" """"""
super().__init__() super().__init__()
self.portfolio_engine = portfolio_engine self.portfolio_engine = portfolio_engine
self.trading_widget = trading_widget self.trading_widget = trading_widget
self.strategy_monitor = strategy_monitor
self.init_ui() self.init_ui()
self.update_combo() self.update_combo()
@ -361,6 +373,8 @@ class StrategyManagementWidget(QtWidgets.QWidget):
) )
self.update_combo() self.update_combo()
self.strategy_monitor.remove_strategy(name)
else: else:
QtWidgets.QMessageBox.warning( QtWidgets.QMessageBox.warning(
self, self,