Deduct open position margin from recommend max lots.

Recalculate tradable symbol budgets from remaining margin after CTP usage and refresh the table on position updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-29 09:39:42 +08:00
parent fd2dba22fd
commit 71c480a587
5 changed files with 96 additions and 8 deletions
+6
View File
@@ -1578,6 +1578,12 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
try:
payload = _refresh_trading_live_snapshot(fast=fast)
position_hub.broadcast("positions", payload)
conn = get_db()
try:
rec = _recommend_payload(conn)
recommend_hub.broadcast("recommend", {"ok": True, **rec})
finally:
conn.close()
except Exception as exc:
logger.debug("push position snapshot: %s", exc)