Speed up CTP account display: refresh equity on fast snapshot without waiting for full position sync.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -88,8 +88,14 @@ def _cached_ctp_account(mode: str) -> dict[str, float]:
|
||||
|
||||
snap = position_hub.get_snapshot() or {}
|
||||
cap = float(snap.get("capital") or 0)
|
||||
if cap > 0:
|
||||
return {"balance": cap}
|
||||
avail = snap.get("account_available")
|
||||
if cap > 0 or avail is not None:
|
||||
out: dict[str, float] = {}
|
||||
if cap > 0:
|
||||
out["balance"] = cap
|
||||
if avail is not None:
|
||||
out["available"] = float(avail)
|
||||
return out
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user