Fix ghost positions: stop showing local monitor when CTP confirms flat account.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-03 23:25:26 +08:00
parent e3b640b35c
commit 59690a4037
2 changed files with 43 additions and 52 deletions
+9 -4
View File
@@ -617,11 +617,16 @@ class CtpBridge:
preserve_margin = 0.0
if self._connected_mode and not positions:
try:
preserve_margin = float(
ctp_account_margin_used(self._connected_mode) or 0,
)
since_ok = time.time() - float(self._last_connect_ok_ts or 0)
except Exception:
preserve_margin = 0.0
since_ok = 9999.0
if since_ok < 180:
try:
preserve_margin = float(
ctp_account_margin_used(self._connected_mode) or 0,
)
except Exception:
preserve_margin = 0.0
trading_state.calibrate_from_lists(
orders,
positions,