Show options-page price clock and drive header trade stats from pure options.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-16 15:59:26 +08:00
parent 82d891ac92
commit 4ade3be2eb
8 changed files with 84 additions and 9 deletions
+21
View File
@@ -5134,6 +5134,16 @@ def render_main_page(page="options", embed_mode=None):
records = []
total = rate = 0
profit_loss_ratio = None
if page == "options" and OKX_OPTIONS_ENABLED:
try:
from lib.options.options_stats_lib import header_options_stats_for_window
opt_header = header_options_stats_for_window(conn, list_window, APP_TZ)
total = opt_header["total"]
rate = opt_header["rate"]
profit_loss_ratio = opt_header.get("profit_loss_ratio")
except Exception:
pass
active_count = len(order_list)
from lib.trade.trade_labels_lib import count_position_limit_active_monitors
@@ -5482,6 +5492,16 @@ def api_account_snapshot():
)
header_trade_stats = header_trade_stats_for_window(conn, _list_window_from_request(), APP_TZ)
page_hint = (request.args.get("page") or "").strip().lower()
if page_hint == "options" and OKX_OPTIONS_ENABLED:
try:
from lib.options.options_stats_lib import header_options_stats_for_window
header_trade_stats = header_options_stats_for_window(
conn, _list_window_from_request(), APP_TZ
)
except Exception:
pass
conn.close()
open_guard_blocks_now = open_guard_enabled and now.hour < TRADING_DAY_RESET_HOUR
from lib.trade.open_trade_gate_lib import resolve_manual_open_gate
@@ -5582,6 +5602,7 @@ def api_account_snapshot():
"total": header_trade_stats["total"],
"rate": header_trade_stats["rate"],
"profit_loss_ratio": header_trade_stats.get("profit_loss_ratio"),
"updated_at": app_now_str(),
"risk_status": risk_status,
**force_close_template_context(
FORCE_CLOSE_ENABLED,