Add OKX env toggle to show or hide perpetual funds in the header.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-05 17:55:15 +08:00
parent 55e94fe059
commit 22e6b68e6d
11 changed files with 105 additions and 10 deletions
+2
View File
@@ -99,6 +99,8 @@ OKX_POSITION_INST_TYPE=SWAP
EXCHANGE_DISPLAY_NAME=OKX
# 企业微信推送里展示的账户备注
# OKX_ACCOUNT_LABEL=
# 顶栏是否显示永续资金账户/交易账户(热更);false 时总资金仅计期权侧
OKX_SHOW_PERP_FUNDS=true
# =============================================================================
# 期权(主账户 API,与永续子账户 OKX_API_* 分离;修改后须重启 PM2)
+14 -5
View File
@@ -6587,6 +6587,7 @@ def render_main_page(page="trade", embed_mode=None):
minimal_stats_bundle,
options_funding_label,
profit_loss_ratio_from_trades,
show_perp_funds_enabled,
total_funds_usdt,
trade_records_summary,
)
@@ -6738,6 +6739,7 @@ def render_main_page(page="trade", embed_mode=None):
_okx_trade_mode = get_okx_trade_mode()
_hedge_mode_on = _okx_trade_mode in ("perp_options", "options_options")
_show_perp_funds = show_perp_funds_enabled(exchange_key="okx")
template_ctx = dict(
page=page,
key=key_list,
@@ -6749,8 +6751,8 @@ def render_main_page(page="trade", embed_mode=None):
rate=rate,
profit_loss_ratio=profit_loss_ratio,
total_funds=total_funds_usdt(
funding_usdt,
current_capital,
funding_usdt if _show_perp_funds else None,
current_capital if _show_perp_funds else None,
options_trading_usdc,
options_funding_usdc,
options_funding_usdt,
@@ -6826,6 +6828,7 @@ def render_main_page(page="trade", embed_mode=None):
options_funding_label=options_funding_label,
exchange_display=EXCHANGE_DISPLAY_NAME,
options_enabled=OKX_OPTIONS_ENABLED,
show_perp_funds=_show_perp_funds,
options_nav_visible=True,
okx_trade_mode=_okx_trade_mode,
options_open_allowed=_okx_trade_mode == "options",
@@ -7025,7 +7028,11 @@ 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
from lib.instance.instance_embed_context_lib import (
header_trade_stats_for_window,
show_perp_funds_enabled,
total_funds_usdt,
)
header_trade_stats = header_trade_stats_for_window(conn, _list_window_from_request(), APP_TZ)
conn.close()
@@ -7076,16 +7083,18 @@ def api_account_snapshot():
unrealized_pnl = merge_unrealized_pnl_components(unrealized_pnl, options_unrealized_pnl)
except Exception:
options_unrealized_pnl = None
_show_perp_funds = show_perp_funds_enabled(exchange_key="okx")
return jsonify({
"funding_usdt": funding_usdt,
"current_capital": current_capital,
"show_perp_funds": _show_perp_funds,
"options_funding_usdc": options_funding_usdc,
"options_funding_usdt": options_funding_usdt,
"options_trading_usdc": options_trading_usdc,
"options_trading_usdt": options_trading_usdt,
"total_funds": total_funds_usdt(
funding_usdt,
current_capital,
funding_usdt if _show_perp_funds else None,
current_capital if _show_perp_funds else None,
options_trading_usdc,
options_funding_usdc,
options_funding_usdt,