Fix OKX header trade stats stuck at zero after settings shell load.

Always SSR records summary on embed shell (including settings/risk/env), and refresh total/win-rate/PL ratio via account_snapshot so soft-nav cannot leave the strip blank.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 13:03:04 +08:00
parent 3a20546782
commit f27b4bc1ec
7 changed files with 72 additions and 5 deletions
+6 -1
View File
@@ -6942,6 +6942,9 @@ def api_account_snapshot():
active_pnl_rows = conn.execute(
"SELECT exchange_symbol, symbol, direction FROM order_monitors WHERE status='active'"
).fetchall()
from lib.instance.instance_embed_context_lib import header_trade_stats_for_window, total_funds_usdt
header_trade_stats = header_trade_stats_for_window(conn, _list_window_from_request(), APP_TZ)
conn.close()
open_guard_blocks_now = open_guard_enabled and now.hour < TRADING_DAY_RESET_HOUR
can_trade = can_trade_new_open(
@@ -6953,7 +6956,6 @@ def api_account_snapshot():
extra_blocks=not risk_status.get("can_trade", True),
)
available_trading_usdt = get_available_trading_usdt()
from lib.instance.instance_embed_context_lib import total_funds_usdt
unrealized_pnl = None
if exchange_private_api_configured():
@@ -7021,6 +7023,9 @@ def api_account_snapshot():
"reset_hour": TRADING_DAY_RESET_HOUR,
"manual_min_planned_rr": MANUAL_MIN_PLANNED_RR,
"trading_day": trading_day,
"total": header_trade_stats["total"],
"rate": header_trade_stats["rate"],
"profit_loss_ratio": header_trade_stats.get("profit_loss_ratio"),
"risk_status": risk_status,
**force_close_template_context(
FORCE_CLOSE_ENABLED,