Fix position flicker, drop futures cooloff, prioritize startup display.

Preserve trading state when CTP memory is empty, bootstrap equity/positions on page load, stabilize risk status from DB monitors, and remove app-layer manual close cooling periods.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-30 23:17:18 +08:00
parent 2386eca324
commit 1b3a7f1bdc
9 changed files with 218 additions and 153 deletions
+9
View File
@@ -553,11 +553,20 @@ class CtpBridge:
orders = self.list_active_orders()
positions = self._collect_positions()
trades = self.list_trades()
preserve_margin = 0.0
if self._connected_mode and not positions:
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,
trades=trades,
ths_for_vnpy_sym=lambda s, e: CtpBridge._vnpy_sym_to_ths(s, e) or s,
preserve_positions_if_margin=preserve_margin,
)
except Exception as exc:
logger.debug("calibrate trading state: %s", exc)