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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user