[Add] stop algo by double click monitor cells
This commit is contained in:
parent
b4081eb01e
commit
d4cab7bfc2
@ -274,7 +274,8 @@ class SpreadAlgoEngine:
|
||||
self.event_engine.register(EVENT_ORDER, self.process_order_event)
|
||||
self.event_engine.register(EVENT_TRADE, self.process_trade_event)
|
||||
self.event_engine.register(EVENT_TIMER, self.process_timer_event)
|
||||
self.event_engine.register(EVENT_SPREAD_DATA, self.process_spread_event)
|
||||
self.event_engine.register(
|
||||
EVENT_SPREAD_DATA, self.process_spread_event)
|
||||
|
||||
def process_spread_event(self, event: Event):
|
||||
""""""
|
||||
@ -311,7 +312,7 @@ class SpreadAlgoEngine:
|
||||
|
||||
def process_timer_event(self, event: Event):
|
||||
""""""
|
||||
buf = self.algos.values()
|
||||
buf = list(self.algos.values())
|
||||
|
||||
for algo in buf:
|
||||
if not algo.is_active():
|
||||
|
@ -103,7 +103,7 @@ class SpreadAlgoTemplate:
|
||||
if self.is_active():
|
||||
self.cancel_all_order()
|
||||
self.status = Status.CANCELLED
|
||||
self.put_algo_event()
|
||||
self.put_event()
|
||||
|
||||
def update_tick(self, tick: TickData):
|
||||
""""""
|
||||
@ -138,7 +138,7 @@ class SpreadAlgoTemplate:
|
||||
|
||||
def put_event(self):
|
||||
""""""
|
||||
self.algo_engine.put_event(self)
|
||||
self.algo_engine.put_algo_event(self)
|
||||
|
||||
def write_log(self, msg: str):
|
||||
""""""
|
||||
|
@ -52,8 +52,7 @@ class SpreadManager(QtWidgets.QWidget):
|
||||
self.event_engine
|
||||
)
|
||||
self.algo_monitor = SpreadAlgoMonitor(
|
||||
self.main_engine,
|
||||
self.event_engine
|
||||
self.spread_engine
|
||||
)
|
||||
|
||||
add_spread_button = QtWidgets.QPushButton("创建价差")
|
||||
@ -164,6 +163,28 @@ class SpreadAlgoMonitor(BaseMonitor):
|
||||
"status": {"display": "状态", "cell": EnumCell, "update": True},
|
||||
}
|
||||
|
||||
def __init__(self, spread_engine: SpreadEngine):
|
||||
""""""
|
||||
super().__init__(spread_engine.main_engine, spread_engine.event_engine)
|
||||
|
||||
self.spread_engine = spread_engine
|
||||
|
||||
def init_ui(self):
|
||||
"""
|
||||
Connect signal.
|
||||
"""
|
||||
super().init_ui()
|
||||
|
||||
self.setToolTip("双击单元格停止算法")
|
||||
self.itemDoubleClicked.connect(self.stop_algo)
|
||||
|
||||
def stop_algo(self, cell):
|
||||
"""
|
||||
Stop algo if cell double clicked.
|
||||
"""
|
||||
algo = cell.get_data()
|
||||
self.spread_engine.stop_algo(algo.algoid)
|
||||
|
||||
|
||||
class SpreadAlgoDialog(QtWidgets.QDialog):
|
||||
""""""
|
||||
|
Loading…
Reference in New Issue
Block a user