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:
dekun
2026-07-01 15:02:37 +08:00
parent a34bcb6bfc
commit 658982d2b9
3 changed files with 101 additions and 14 deletions
+8 -2
View File
@@ -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: