Fix ghost positions: stop showing local monitor when CTP confirms flat account.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user