Auto-cancel stale option close limits after pending TTL.

Default 10m via OKX_OPTIONS_PENDING_TTL_SECONDS; show age/countdown in pending panel; monitor loop cancels sell closes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-15 22:06:24 +08:00
parent ee7be3e7f3
commit cbb7f954f5
12 changed files with 306 additions and 15 deletions
+7
View File
@@ -272,6 +272,7 @@ def options_monitor_loop(
profit_ratio: float,
sync_trades_fn: Callable[[sqlite3.Connection], int] | None = None,
target_close_fn: Callable[[str], dict[str, Any]] | None = None,
stale_pending_fn: Callable[[], dict[str, Any]] | None = None,
stop_event: Any = None,
) -> None:
if not enabled:
@@ -306,6 +307,12 @@ def options_monitor_loop(
conn.commit()
finally:
conn.close()
# 平仓限价挂单超时撤单(独立于 DB 事务)
if stale_pending_fn is not None:
try:
stale_pending_fn()
except Exception:
pass
except Exception:
pass
time.sleep(max(5.0, float(poll_seconds)))