feat: add OKX options module with dual API, USDT/USDC convert, and docs
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,7 @@ EMBED_TABS: tuple[str, ...] = (
|
||||
"trade",
|
||||
"strategy",
|
||||
"strategy_records",
|
||||
"options",
|
||||
"records",
|
||||
"stats",
|
||||
"settings",
|
||||
@@ -28,6 +29,7 @@ PATH_TO_EMBED_TAB: dict[str, str] = {
|
||||
"/strategy/trend": "strategy",
|
||||
"/strategy/roll": "strategy",
|
||||
"/strategy/records": "strategy_records",
|
||||
"/options": "options",
|
||||
"/records": "records",
|
||||
"/stats": "stats",
|
||||
"/settings": "settings",
|
||||
|
||||
@@ -135,6 +135,27 @@ def build_instance_settings_view(
|
||||
}
|
||||
)
|
||||
|
||||
if (exchange_key or "").strip().lower() == "okx" and _env_bool("OKX_OPTIONS_ENABLED", False):
|
||||
opt_key = (os.getenv("OKX_OPTIONS_API_KEY") or "").strip()
|
||||
sections.append(
|
||||
{
|
||||
"title": "期权账户(主账户)",
|
||||
"rows": [
|
||||
_row("期权模块", "已启用"),
|
||||
_row(
|
||||
"期权 API",
|
||||
f"已配置(…{opt_key[-4:]})" if len(opt_key) >= 4 else "未配置",
|
||||
),
|
||||
_row("单笔权利金上限", f"{_env_float('OKX_OPTIONS_TRADE_BUDGET_USDC', 10):g} USDC"),
|
||||
_row(
|
||||
"资金说明",
|
||||
"资金账户 USDT 兑换 USDC 后划转到交易账户",
|
||||
"期权页操作;与永续子账户资金分开",
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
policy_note = ""
|
||||
if trade_policy and getattr(trade_policy, "badge_text", ""):
|
||||
policy_note = str(trade_policy.badge_text)
|
||||
|
||||
@@ -206,6 +206,8 @@
|
||||
{% include 'strategy_trading_page.html' %}
|
||||
{% elif page == 'strategy_records' %}
|
||||
{% include 'strategy_records_page.html' %}
|
||||
{% elif page == 'options' %}
|
||||
{% include 'options_panel.html' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
{% 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 %}
|
||||
<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>
|
||||
</nav>
|
||||
<div id="embed-flash" class="flash" style="display:none" role="status"></div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<link rel="manifest" href="/static/icons/manifest.webmanifest">
|
||||
<title>{{ exchange_display }} · 加密货币 | 交易监控复盘系统</title>
|
||||
<link rel="stylesheet" href="/static/instance_page.css?v=1">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=60">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=61">
|
||||
|
||||
</head>
|
||||
<body
|
||||
@@ -61,14 +61,17 @@
|
||||
{% endif %}
|
||||
<a href="/records" class="{% if page == 'records' %}active{% endif %}">交易记录与复盘</a>
|
||||
<a href="/stats" class="{% if page == 'stats' %}active{% endif %}">统计分析</a>
|
||||
{% if options_enabled %}
|
||||
<a href="/options" class="{% if page == 'options' %}active{% endif %}">期权</a>
|
||||
{% endif %}
|
||||
<a href="/settings" class="{% if page == 'settings' %}active{% endif %}">系统设置</a>
|
||||
</div>
|
||||
{% with msg=get_flashed_messages() %}{% if msg %}<div class="flash">{{ msg[0] }}</div>{% endif %}{% endwith %}
|
||||
|
||||
{% if page != 'settings' %}
|
||||
{% if page != 'settings' and page != 'options' %}
|
||||
{% include 'instance_header_panel.html' %}
|
||||
{% endif %}
|
||||
{% if page != 'settings' %}
|
||||
{% if page != 'settings' and page != 'options' %}
|
||||
{% include 'instance_top_bar.html' %}
|
||||
{% endif %}
|
||||
|
||||
@@ -275,6 +278,8 @@
|
||||
{% include 'strategy_trading_page.html' %}
|
||||
{% elif page == 'strategy_records' %}
|
||||
{% include 'strategy_records_page.html' %}
|
||||
{% elif page == 'options' %}
|
||||
{% include 'options_panel.html' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user