Restore stop-loss and take-profit monitors after restart and CTP reconnect.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 09:24:37 +08:00
parent 963ed141e5
commit ec4199b82c
2 changed files with 68 additions and 7 deletions
+10 -2
View File
@@ -614,8 +614,16 @@ def reconcile_monitors_without_position(conn, mode: str, *, grace_sec: int = 120
position_keys.add((sym, direction))
margin_used = ctp_account_margin_used(mode) or 0.0
if not position_keys and margin_used > 300:
return 0
if not position_keys:
if margin_used > 100:
return 0
try:
bridge = get_bridge()
since_connect = time.time() - float(getattr(bridge, "_last_connect_ok_ts", 0) or 0)
if since_connect < 180:
return 0
except Exception:
return 0
now_ts = time.time()