Match options branding: title prefix and ETH/BTC header quotes.

Use 「加密货币 | OKX 对冲」 and show live top-right ETHUSDT/BTCUSDT quotes like the options instance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 19:17:00 +08:00
parent fc83905cf6
commit 22de1fd40c
8 changed files with 301 additions and 9 deletions
+38
View File
@@ -7134,6 +7134,36 @@ def options_main_page():
return render_main_page("options")
@app.route("/api/header-quotes")
@login_required
def api_header_quotes():
"""顶栏 ETH/BTC 报价(公共 ticker last + 24h 涨跌)."""
from lib.exchange.okx_public_http_lib import fetch_swap_ticker
quotes = []
for base in ("ETH", "BTC"):
item: dict = {"base": base, "symbol": f"{base}USDT"}
try:
row = fetch_swap_ticker(base)
last = float(row.get("last") or row.get("markPx") or 0)
open24 = float(row.get("open24h") or row.get("sodUtc0") or 0)
change = (last - open24) if open24 > 0 else 0.0
pct = (change / open24 * 100.0) if open24 > 0 else 0.0
item.update(
{
"last": last,
"open24h": open24,
"change": change,
"pct": pct,
"mark": float(row.get("markPx") or last or 0) or None,
}
)
except Exception as e:
item["error"] = str(e)[:160]
quotes.append(item)
return jsonify({"ok": True, "quotes": quotes})
@app.route("/api/account_snapshot")
@login_required
def api_account_snapshot():
@@ -9408,6 +9438,7 @@ _OPTIONS_PANEL_JS = os.path.join(_REPO_STATIC_DIR, "options_panel.js")
_OPTIONS_EXPIRY_COUNTDOWN_JS = os.path.join(_REPO_STATIC_DIR, "options_expiry_countdown.js")
_OPTIONS_SETTINGS_JS = os.path.join(_REPO_STATIC_DIR, "options_settings.js")
_HEDGE_PLAN_JS = os.path.join(_REPO_STATIC_DIR, "hedge_plan.js")
_HEADER_LIVE_QUOTES_JS = os.path.join(_REPO_STATIC_DIR, "header_live_quotes.js")
@app.route("/static/ai_review_render.js")
@@ -9417,6 +9448,13 @@ def static_ai_review_render_js():
return send_file(_AI_REVIEW_RENDER_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/header_live_quotes.js")
def static_header_live_quotes_js():
if not os.path.isfile(_HEADER_LIVE_QUOTES_JS):
return Response("not found", status=404, mimetype="text/plain; charset=utf-8")
return send_file(_HEADER_LIVE_QUOTES_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/form_submit_guard.js")
def static_form_submit_guard_js():
if not os.path.isfile(_FORM_SUBMIT_GUARD_JS):