Add options index target monitors that auto limit-close on hit.

Position and order forms can arm a target; right-side and hub panels show active monitors; expiry remains the stop with no separate SL.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-15 15:27:46 +08:00
parent 8d2da921ee
commit d6823a2903
13 changed files with 1011 additions and 18 deletions
+11
View File
@@ -271,6 +271,7 @@ def options_monitor_loop(
account_label: str,
profit_ratio: float,
sync_trades_fn: Callable[[sqlite3.Connection], int] | None = None,
target_close_fn: Callable[[str], dict[str, Any]] | None = None,
stop_event: Any = None,
) -> None:
if not enabled:
@@ -290,6 +291,16 @@ def options_monitor_loop(
account_label=account_label,
ticker_bid_fn=ticker_bid_fn,
)
if target_close_fn is not None:
from lib.options.options_target_lib import run_options_target_closes
run_options_target_closes(
conn,
positions,
close_fn=target_close_fn,
send_wechat=send_wechat,
account_label=account_label,
)
if sync_trades_fn is not None:
sync_trades_fn(conn)
conn.commit()