fix: always show OKX options nav tab and allow options page without redirect
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
{% endif %}
|
||||
<a href="/records" data-embed-tab="records" class="{% if initial_tab == 'records' %}active{% endif %}">交易记录与复盘</a>
|
||||
<a href="/stats" data-embed-tab="stats" class="{% if initial_tab == 'stats' %}active{% endif %}">统计分析</a>
|
||||
{% if options_enabled %}
|
||||
{% if options_nav_visible %}
|
||||
<a href="/options" data-embed-tab="options" class="{% if initial_tab == 'options' %}active{% endif %}">期权</a>
|
||||
{% endif %}
|
||||
<a href="/settings" data-embed-tab="settings" class="{% if initial_tab == 'settings' %}active{% endif %}">系统设置</a>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
{% endif %}
|
||||
<a href="/records" class="{% if page == 'records' %}active{% endif %}">交易记录与复盘</a>
|
||||
<a href="/stats" class="{% if page == 'stats' %}active{% endif %}">统计分析</a>
|
||||
{% if options_enabled %}
|
||||
{% if options_nav_visible %}
|
||||
<a href="/options" class="{% if page == 'options' %}active{% endif %}">期权</a>
|
||||
{% endif %}
|
||||
<a href="/settings" class="{% if page == 'settings' %}active{% endif %}">系统设置</a>
|
||||
|
||||
@@ -52,8 +52,8 @@ def install_options_trading(app: Flask, repo_root: str, app_module: Any) -> None
|
||||
attach_options_templates(app, repo_root)
|
||||
cfg = _build_cfg(app_module)
|
||||
app.extensions["options_cfg"] = cfg
|
||||
register_options_routes(app, cfg)
|
||||
if enabled:
|
||||
register_options_routes(app, cfg)
|
||||
_start_monitor_thread(app, cfg)
|
||||
|
||||
|
||||
@@ -102,10 +102,12 @@ def _build_cfg(app_module: Any) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _require_options_ex(cfg: dict[str, Any]):
|
||||
if not cfg.get("enabled"):
|
||||
return None, "期权模块未启用,请在 .env 设置 OKX_OPTIONS_ENABLED=true 并重启 PM2"
|
||||
ex = cfg.get("exchange_options")
|
||||
ok, reason = cfg["options_api_ready"](ex)
|
||||
if not ok:
|
||||
return None, reason
|
||||
return None, reason or "期权 API 未配置"
|
||||
return ex, ""
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
data-trade-budget="{{ options_trade_budget | default(10) }}"
|
||||
data-default-underly="{{ options_default_underly | default('ETH') }}">
|
||||
<h2>期权(USDⓈ 本位 · 仅买方)</h2>
|
||||
{% if not options_enabled %}
|
||||
<div class="flash" style="margin-bottom:12px">期权 API 未启用:请在 <code>crypto_monitor_okx/.env</code> 设置 <code>OKX_OPTIONS_ENABLED=true</code> 及主账户 <code>OKX_OPTIONS_API_*</code>,然后 <code>pm2 restart crypto_okx --update-env</code>。</div>
|
||||
{% endif %}
|
||||
<p class="muted options-hint">资金账户兑换 USDT→USDC 后,划转到交易账户即可买入。报价单位为每 1 ETH/BTC;1 张 = 0.01 ETH/BTC。</p>
|
||||
|
||||
<div class="options-funds-grid">
|
||||
|
||||
Reference in New Issue
Block a user