Files
CoinOX/lib/hedge_plan/templates/hedge_plan_panel.html
T
dekun 1d8c38e320 Fetch option Delta from OKX opt-summary into the chain.
market/tickers has no greeks; merge public/opt-summary delta/gamma when building the strike table.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-14 22:02:25 +08:00

513 lines
36 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<div class="hedge-plan-page-wrap" style="grid-column:1/-1" id="hedge-plan-root"
data-default-underly="{{ hedge_option_underlying or options_default_underly | default('ETH') }}"
data-po-mode="{{ hedge_po_mode | default('eth') }}"
data-po-mode-label="{{ hedge_po_mode_label | default('ETH永期') }}"
data-option-underly="{{ hedge_option_underlying or options_default_underly | default('ETH') }}"
data-perp-underly="{{ hedge_perp_underlying or options_default_underly | default('ETH') }}"
data-cross-asset="{{ '1' if hedge_cross_asset else '0' }}"
data-cross-k="{{ hedge_cross_notional_k if hedge_cross_notional_k is not none else '' }}"
data-option-perp-ratio="{{ hedge_option_perp_ratio | default(2) }}"
data-hedge-enabled="{{ '1' if hedge_plan_enabled else '0' }}"
data-options-enabled="{{ '1' if options_enabled else '0' }}"
data-show-perp="{{ '1' if hedge_plan_show_perp_options else '0' }}"
data-show-oo="{{ '1' if hedge_plan_show_options_options else '0' }}"
data-oo-close-mode-enabled="{{ '1' if hedge_plan_oo_close_mode_enabled else '0' }}"
data-option-primary="{{ '1' if hedge_plan_option_primary|default(true) else '0' }}"
data-budget-buffer="{{ hedge_plan_budget_buffer | default(0.95) }}"
data-btc-leverage="{{ hedge_plan_btc_leverage | default(10) }}"
data-eth-leverage="{{ hedge_plan_eth_leverage | default(5) }}"
data-sizing-mode="{{ position_sizing_mode | default('risk') }}"
data-is-full-margin="{{ '1' if position_sizing_mode == 'full_margin' else '0' }}">
{% if not hedge_plan_enabled %}
<div class="flash" style="margin-bottom:12px">对冲计划未启用:请在 <code>env配置 → 对冲计划</code> 打开 <code>HEDGE_PLAN_ENABLED</code>(可热更).</div>
{% endif %}
{% if not options_enabled %}
<div class="flash" style="margin-bottom:12px">期权模块未启用,无法拉期权链.请先配置期权账户.</div>
{% endif %}
{% if hedge_plan_enabled and not hedge_plan_show_perp_options and not hedge_plan_show_options_options %}
<div class="flash" style="margin-bottom:12px">永期与期期 Tab 均已隐藏:请在 env「期权/对冲模式」切换交易模式.</div>
{% endif %}
{# 顶栏「对冲计划」已改为导航「永期/期期对冲」;页内不再重复大标题 #}
<div class="hp-page-toolbar">
<button type="button" class="btn-secondary" id="hp-refresh" title="刷新永续行情与期权链">刷新行情</button>
<span class="hp-po-mode-badge" id="hp-po-mode-badge" title="一实例一种模式对应一个子账户;模拟与实盘同路径">{{ hedge_po_mode_label | default('ETH永期') }}</span>
<span class="muted hp-po-gate-inline" id="hp-po-gate-inline" aria-live="polite"></span>
</div>
{# 模式由导航/env 决定,页内不再显示「永期对冲」Tab #}
<div class="hp-tabs" role="tablist" aria-label="对冲模式" hidden style="display:none!important">
{% if hedge_plan_show_perp_options %}
<button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="perp_options">永期对冲</button>
{% endif %}
{% if hedge_plan_show_options_options %}
<button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="options_options">期期对冲</button>
{% endif %}
</div>
<p class="muted" id="hp-gate-line" hidden></p>
<p class="muted hp-acct-hint" id="hp-acct-hint" hidden>永续腿→合约账户 · 期权腿→期权账户</p>
<div id="hp-tab-perp_options" class="hp-tab-panel" role="tabpanel">
<div class="options-dual-grid" id="hp-po-layout">
<!-- 左:选约(点选择→弹窗下单) -->
<div class="card hp-po-left-card hp-po-select-card options-order-card">
<h2>手动选约 · <span id="hp-opt-type-label">Call</span> <span class="muted hp-acct-tag" id="hp-opt-acct-tag">币本位</span></h2>
<details class="tip-collapse hp-rule-collapse">
<summary class="tip-collapse-summary">规则说明</summary>
<div class="tip-collapse-body rule-tip">
<p><strong>实例模式</strong>:<code>HEDGE_PO_MODE</code>=<strong>{{ hedge_po_mode | default('eth') }}</strong>({{ hedge_po_mode_label | default('ETH永期') }})。一实例一种模式对应一个子账户;模拟盘与实盘同一执行路径;账户互不干涉。不可页内切换。</p>
<p><strong>腿组合</strong>:期权 <strong>{{ hedge_option_underlying or 'ETH' }}</strong> + 永续 <strong>{{ hedge_perp_underlying or 'ETH' }}</strong>{% if hedge_cross_asset %};跨币名义系数 K=<strong>{{ hedge_cross_notional_k or 0.5 }}</strong>(永续名义=期权名义×K){% endif %}。买 Call → 永续空;买 Put → 永续多。比例默认 <strong>{{ hedge_option_perp_ratio | default(2) }}</strong>。</p>
<p><strong>手动下单</strong>:开仓按<strong>卖一限价</strong>(非交易所市价)。先开期权(按张数买币并+5%滑点),再开永续。永续杠杆取 env:BTC=<code>BTC_LEVERAGE</code>/ETH=<code>ALT_LEVERAGE</code>。</p>
<p><strong>出场</strong>:仅<strong>组合盈利金额(U)</strong>(期权净利×期权指数 + 永续净利,扣开平双边手续费)。平仓先期权(须买一流动性)再永续,再把期权标的币卖回 USDT。一账户同时仅一笔对冲仓。</p>
<p><strong>开仓校验</strong>:已选合约 · 张数≥1 · 盈利目标已填 · 门禁「开仓:可」· 账户有足够交易 USDT。</p>
<p><strong>期权链</strong>:默认显示约 <strong>5</strong> 档(平值 + 实值2 + 虚值2);勾选「展开全部」查看该到期更多行权价。</p>
<p><strong>账户</strong>:期权币本位 · 交易/资金计 USDT · 永续全仓 / 期权逐仓(余额见下方划转)。</p>
<p><strong>组合净盈亏</strong>:扣开平双边手续费;永续按平仓方向盘口均价估值;一律折 U。</p>
<p class="muted" id="hp-po-pair-hint">买 Call + 永续空 · 点「选择」弹窗下单。</p>
</div>
</details>
<div class="form-row hp-opt-toolbar hp-po-opt-toolbar options-chain-toolbar">
<span class="hp-uly-lock" id="hp-uly-lock" title="由 HEDGE_PO_MODE 锁定,本实例仅此标的">
<span class="muted hp-uly-lab">标的</span>
<strong class="hp-uly-single" id="hp-uly-single" aria-live="polite">{{ hedge_option_underlying or options_default_underly or 'ETH' }}</strong>
</span>
<select id="hp-exp-select"><option value="">选择到期日</option></select>
<span class="hp-oo-seg hp-po-dir-seg" role="group" aria-label="期权类型">
<button type="button" class="btn-secondary hp-po-dir is-selected" data-dir="long" title="买 Call → 永续空"><span class="hp-oo-check" aria-hidden="true">✓</span>看涨 Call</button>
<button type="button" class="btn-secondary hp-po-dir" data-dir="short" title="买 Put → 永续多"><span class="hp-oo-check" aria-hidden="true">✓</span>看跌 Put</button>
</span>
<span class="hp-po-ins-money" id="hp-po-ins-money" hidden>
<button type="button" class="btn-secondary hp-money-btn active" data-money="itm" title="实值+平值">实值/平值</button>
<button type="button" class="btn-secondary hp-money-btn" data-money="atm" title="仅平值">仅平值</button>
</span>
<span class="hp-po-mkt-money" id="hp-po-mkt-money">
<button type="button" class="btn-secondary hp-money-btn active" data-money="all" title="全部行权价(默认窗口)">全部</button>
<button type="button" class="btn-secondary hp-money-btn" data-money="itm" title="实值(含平值)">实值</button>
<button type="button" class="btn-secondary hp-money-btn" data-money="otm" title="虚值">虚值</button>
</span>
<label class="opt-strike-expand-label hp-po-expand-label" title="展开该到期全部行权价">
<input type="checkbox" id="hp-strike-expand-all"> 展开全部
</label>
<button type="button" class="btn-secondary" id="hp-load-chain">刷新链</button>
<span id="hp-index-line" class="hp-po-index" aria-live="polite">指数 —</span>
</div>
<input type="hidden" id="hp-min-hours" value="0" />
<input type="hidden" id="hp-strike-interval" value="0" />
<input type="hidden" id="hp-opt-leverage" value="0" />
<input type="hidden" id="hp-money-select" value="all" />
<input type="hidden" id="hp-sheets" value="1" />
<input type="hidden" id="hp-premium-budget" value="0" />
<div class="options-strike-table-wrap hp-strike-table-wrap--6">
<table class="options-strike-table" id="hp-strike-table">
<thead>
<tr>
<th>行权价</th>
<th>类型</th>
<th title="交易所 Delta:标的变动时期权价敏感度;实值 |Δ| 通常更大(Call为正/Put为负)">Delta</th>
<th>合约</th>
<th>卖一/张</th>
<th title="币本位:1÷卖一">杠杆</th>
<th>买一/张</th>
<th>操作</th>
</tr>
</thead>
<tbody id="hp-strike-tbody">
<tr><td colspan="8" class="muted">请刷新期权链</td></tr>
</tbody>
</table>
</div>
<div id="hp-opt-bal-line" class="muted hp-po-meta hp-opt-bal-line" hidden aria-hidden="true"></div>
<div class="hp-oo-transfer hp-oo-transfer--compact" id="hp-po-transfer">
<div class="hp-oo-transfer-bals muted">
<span>资金 <strong id="hp-po-funding-usdt">—</strong></span>
<span class="hp-oo-transfer-sep">·</span>
<span>交易 <strong id="hp-po-trading-usdt">—</strong></span>
<span class="hp-oo-transfer-unit">USDT</span>
<span class="muted" id="hp-po-xfer-msg"></span>
</div>
<div class="form-row hp-oo-transfer-form" autocomplete="off">
<input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0" value="">
<select id="hp-po-xfer-ccy" aria-label="币种" autocomplete="off">
<option value="USDT" selected>USDT</option>
<option value="ETH">ETH</option>
<option value="BTC">BTC</option>
</select>
<select id="hp-po-xfer-dir" aria-label="划转方向" autocomplete="off">
<option value="funding_to_trading" selected>资金 → 交易</option>
<option value="trading_to_funding">交易 → 资金</option>
</select>
<input type="number" id="hp-po-xfer-amount" name="cm_hp_po_xfer_amt" min="0.01" step="any" placeholder="数量"
autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-bwignore="true" data-form-type="other" readonly />
<button type="button" class="btn-secondary btn-sm" id="hp-po-xfer-all">全部</button>
<button type="button" class="btn-primary btn-sm" id="hp-po-xfer-btn">划转</button>
</div>
</div>
<!-- 弹窗下单:宽屏左测算 / 右下单 -->
<div id="hp-order-panel-host" class="opt-order-backdrop" hidden aria-hidden="true">
<div id="hp-order-panel" class="opt-order-dialog hp-po-order-dialog hp-po-order-dialog--wide" role="dialog" aria-modal="true" aria-labelledby="hp-order-dialog-title" style="display:none">
<div class="opt-order-dialog-head">
<h3 class="opt-order-title" id="hp-order-dialog-title">手动下单 · <span id="hp-perp-uly-label">ETH</span></h3>
<button type="button" class="hp-po-dialog-x" id="hp-order-close-btn" aria-label="关闭">×</button>
</div>
<div class="opt-order-layout hp-po-order-split">
<aside class="hp-po-order-calc-pane" aria-label="仓位测算">
<h4 class="hp-po-section-title">仓位测算</h4>
<div class="hp-po-dialog-meta">
<div id="hp-sel-inst" class="options-order-inst">—</div>
<p class="muted hp-po-dialog-sub" id="hp-premium-line"></p>
<p class="muted hp-po-dialog-sub" id="hp-po-mark" aria-live="polite">标记 —</p>
<p id="hp-perp-quote" class="muted hp-po-dialog-sub" hidden>加载中…</p>
<p id="hp-po-perp-quote-right" class="muted" hidden></p>
</div>
<div class="hp-po-calc-box">
<p class="muted hp-po-max-line" id="hp-po-max-line">期权开仓最大 —</p>
<p class="muted hp-po-perp-auto" id="hp-po-perp-auto">永续开仓 —</p>
<div id="hp-perp-pnl-line" class="hp-po-pnl"></div>
<div id="hp-sizing-line" class="muted hp-po-sizing"></div>
</div>
<span id="hp-po-mode-badge" class="hp-po-mode-badge" hidden>手动下单</span>
<span id="hp-po-card-title" hidden>下单</span>
<span class="muted hp-acct-tag" id="hp-perp-acct-tag" hidden>合约账户</span>
</aside>
<div class="opt-order-main hp-po-order-form-pane">
<div class="hp-po-fields hidden" id="hp-po-fields-insurance" hidden>
<label class="hp-po-field">
<span class="hp-po-field-lab">开仓价 <em>USDT</em></span>
<input type="number" step="any" id="hp-entry" placeholder="入场价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field">
<span class="hp-po-field-lab">张数 <em>合约张</em></span>
<input type="number" step="any" id="hp-contracts" placeholder="数量" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field hp-po-field--tp">
<span class="hp-po-field-lab">止盈 <em>USDT</em></span>
<input type="number" step="any" id="hp-tp" placeholder="目标价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field hp-po-field--sl">
<span class="hp-po-field-lab">止损 <em>USDT</em></span>
<input type="number" step="any" id="hp-sl" placeholder="保护价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
</div>
<div id="hp-po-fields-option-primary" class="hp-po-dialog-body">
<section class="hp-po-section">
<h3 class="hp-po-section-title">开仓</h3>
<div class="hp-po-fields hp-po-fields--section hp-po-fields--capital">
<label class="hp-po-field">
<span class="hp-po-field-lab">张数 <em>期权张</em></span>
<input type="number" step="1" min="1" id="hp-order-sheets" value="1" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field">
<span class="hp-po-field-lab">比例 <em>期权:永续</em></span>
<input type="number" step="any" min="0.1" id="hp-opt-perp-ratio" value="2" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field">
<span class="hp-po-field-lab">永续杠杆 <em>env</em></span>
<input type="number" step="1" id="hp-perp-leverage" value="{{ hedge_plan_eth_leverage | default(5) }}" readonly autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" title="BTC=BTC_LEVERAGE ETH=ALT_LEVERAGE" />
</label>
</div>
</section>
<section class="hp-po-section">
<h3 class="hp-po-section-title">出场条件</h3>
<div class="hp-oo-seg hp-po-exit-seg" role="group" aria-label="出场方式">
<button type="button" class="btn-secondary hp-po-exit-mode is-selected" data-exit="profit"><span class="hp-oo-check" aria-hidden="true">✓</span>盈利金额</button>
<button type="button" class="btn-secondary hp-po-exit-mode" data-exit="target"><span class="hp-oo-check" aria-hidden="true">✓</span>目标位</button>
</div>
<div class="hp-po-fields hp-po-fields--section" id="hp-po-exit-profit">
<label class="hp-po-field hp-po-field--wide">
<span class="hp-po-field-lab">目标盈利 <em>USDT</em></span>
<input type="number" step="any" min="0.01" id="hp-profit-target" placeholder="扣双边手续费后净利" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" required />
</label>
</div>
<div class="hp-po-fields hp-po-fields--section hidden" id="hp-po-exit-target" hidden>
<label class="hp-po-field">
<span class="hp-po-field-lab">期权目标位 <em>相对K</em></span>
<input type="number" step="any" id="hp-opt-target-pts" placeholder="点数" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="hp-po-field">
<span class="hp-po-field-lab">永续目标位 <em>相对K</em></span>
<input type="number" step="any" id="hp-perp-target-pts" placeholder="点数" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
</div>
<p class="err hp-po-order-err" id="hp-po-order-err" hidden></p>
</section>
</div>
<div class="opt-order-dialog-actions">
<span id="hp-po-strategy-status" class="hp-po-strategy-status" aria-live="polite"></span>
<button type="button" class="btn-secondary" id="hp-order-cancel-btn">取消</button>
<button type="button" class="btn-primary" id="hp-preview-btn" title="卖一限价开期权+永续对冲">手动下单</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 右:持仓(当前持仓/委托/历史/统计) -->
<div class="card options-pos-card-wrap hp-po-pos-card">
<div class="options-pos-head">
<h2>持仓</h2>
<div class="options-pos-head-actions">
<button type="button" class="btn-secondary" id="hp-sell-coin-btn" hidden title="市价卖出交易账户全部可用标的币(当前选中 ETH/BTC)换回 USDT">手动卖回币</button>
<button type="button" class="btn-secondary" id="hp-pos-refresh" title="刷新持仓与历史">刷新</button>
</div>
</div>
<div class="muted" id="hp-sell-coin-msg" hidden style="font-size:.72rem;margin:0 0 6px"></div>
<div class="options-pos-tabs" role="tablist" aria-label="永期持仓面板">
<button type="button" class="btn-secondary opt-pos-tab hp-pos-tab active" data-hp-pos-tab="live" role="tab" aria-selected="true">当前持仓</button>
<button type="button" class="btn-secondary opt-pos-tab hp-pos-tab" data-hp-pos-tab="plans" role="tab" aria-selected="false">对冲计划</button>
<button type="button" class="btn-secondary opt-pos-tab hp-pos-tab" data-hp-pos-tab="pending" role="tab" aria-selected="false">当前委托</button>
<button type="button" class="btn-secondary opt-pos-tab hp-pos-tab" data-hp-pos-tab="history" role="tab" aria-selected="false">历史记录</button>
<button type="button" class="btn-secondary opt-pos-tab hp-pos-tab" data-hp-pos-tab="stats" role="tab" aria-selected="false">统计分析</button>
</div>
<div class="options-pos-tab-body">
<div class="options-pos-pane is-active" data-hp-pos-pane="live" role="tabpanel">
<div id="hp-live-pos-list" class="hp-live-pos-list">
<p class="muted">加载中…</p>
</div>
</div>
<div class="options-pos-pane" data-hp-pos-pane="plans" role="tabpanel" hidden>
<div class="options-strike-table-wrap">
<table class="options-strike-table hp-history-table">
<thead>
<tr>
<th>ID</th><th>类型</th><th>标的</th><th>合约</th><th>状态</th><th>目标/止盈止损</th><th>开仓</th><th>操作</th>
</tr>
</thead>
<tbody id="hp-active-tbody">
<tr><td colspan="8" class="muted">加载中…</td></tr>
</tbody>
</table>
</div>
</div>
<div class="options-pos-pane" data-hp-pos-pane="pending" role="tabpanel" hidden>
<p class="muted" style="margin:0 0 8px;font-size:.82rem">盯盘中 / 待成交计划</p>
<div class="options-strike-table-wrap">
<table class="options-strike-table hp-history-table">
<thead>
<tr>
<th>ID</th><th>类型</th><th>标的</th><th>合约</th><th>状态</th><th>说明</th><th>开仓</th><th>操作</th>
</tr>
</thead>
<tbody id="hp-pending-tbody">
<tr><td colspan="8" class="muted">暂无委托</td></tr>
</tbody>
</table>
</div>
</div>
<div class="options-pos-pane" data-hp-pos-pane="history" role="tabpanel" hidden>
<div class="options-strike-table-wrap">
<table class="options-strike-table hp-history-table">
<thead>
<tr>
<th>ID</th><th>类型</th><th>标的</th><th>合约</th><th>状态</th><th>合计≈U</th><th>原因</th><th>开仓</th><th>结束</th><th>操作</th>
</tr>
</thead>
<tbody id="hp-history-tbody">
<tr><td colspan="10" class="muted">加载中…</td></tr>
</tbody>
</table>
</div>
</div>
<div class="options-pos-pane" data-hp-pos-pane="stats" role="tabpanel" hidden>
<p class="muted" style="margin:0 0 8px;font-size:.82rem">按永期 / 期期分别统计</p>
<div id="hp-stats-box" class="muted">加载中…</div>
</div>
</div>
</div>
</div>
</div>
<div id="hp-tab-options_options" class="hp-tab-panel hidden" role="tabpanel" hidden>
<div class="options-dual-grid" id="hp-oo-layout">
<div class="card">
<h2>期期参数 · <span id="hp-oo-uly-label">ETH</span> <span class="muted hp-acct-tag">期权账户</span></h2>
<details class="tip-collapse hp-rule-collapse">
<summary class="tip-collapse-summary">规则说明</summary>
<div class="tip-collapse-body rule-tip">
<p><strong>账户</strong>:两腿都走<strong>币本位期权</strong>。可用预算 = min(交易 USDT × 对冲缓冲 <strong id="hp-oo-buf-ratio">{{ '%.2f'|format(hedge_plan_budget_buffer|default(0.95)|float) }}</strong>, 单笔预算);可在 env「对冲预算缓冲比例」改。</p>
<p><strong>下单</strong>:选 Call + Put 后「计算」再「启动」。启动会再拉卖一并按最新价重算张数,IOC 完全成交才算成功;资金不足可在右侧划转。</p>
<p><strong>板块</strong>:左填<strong>盈亏比</strong>(盈利金额÷总权利金,默认2)与张数模式(同张数/做多/做空);右 T 型选腿。<strong>两腿仅允许平值或虚值</strong>(禁实值)。出场:盈利腿达盈亏比即平;亏损腿「残值平」=本合约权利金跌至20%且有买一时平,「到期平」=持有至到期。</p>
</div>
</details>
<div class="form-row hp-uly-row">
<button type="button" class="btn-secondary hp-uly-btn-oo active" data-uly="ETH">ETH</button>
<button type="button" class="btn-secondary hp-uly-btn-oo" data-uly="BTC">BTC</button>
</div>
<div class="form-row hp-target-row hp-oo-target-row">
<label title="盈利金额 / 总权利金">盈亏比 <input type="number" step="0.1" min="0.1" id="hp-profit-rr" value="2" placeholder="默认2" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>
<span id="hp-oo-index" class="hp-oo-index" aria-live="polite">指数 —</span>
</div>
<div class="hp-oo-controls">
<div class="hp-oo-ctrl">
<span class="hp-oo-ctrl-lab">张数</span>
<div class="hp-oo-seg" role="group" aria-label="自动张数">
<button type="button" class="btn-secondary hp-oo-size-mode is-selected" data-oo-size="same_sheets" title="两腿同张数,总权利金≤预算"><span class="hp-oo-check" aria-hidden="true">✓</span>同张数</button>
<button type="button" class="btn-secondary hp-oo-size-mode" data-oo-size="long_bias" title="偏多:Call 占比更高(比例见 env)"><span class="hp-oo-check" aria-hidden="true">✓</span>做多</button>
<button type="button" class="btn-secondary hp-oo-size-mode" data-oo-size="short_bias" title="偏空:Put 占比更高(比例见 env)"><span class="hp-oo-check" aria-hidden="true">✓</span>做空</button>
</div>
</div>
<div class="hp-oo-ctrl" id="hp-oo-close-mode-row">
<span class="hp-oo-ctrl-lab" title="仅控制盈利腿平掉后的另一腿">平仓</span>
<div class="hp-oo-seg" role="group" aria-label="平仓模式">
<button type="button" class="btn-secondary hp-oo-close-mode is-selected" data-oo-close="close_all" title="盈利腿平后:亏损腿本合约权利金跌至20%且有买一时平掉(失败重试)"><span class="hp-oo-check" aria-hidden="true">✓</span>残值平</button>
<button type="button" class="btn-secondary hp-oo-close-mode" data-oo-close="hold_expiry" title="盈利腿平后另一腿持有至到期"><span class="hp-oo-check" aria-hidden="true">✓</span>到期平</button>
</div>
</div>
</div>
<p class="muted hp-oo-meta" id="hp-oo-budget-line"></p>
<div id="hp-oo-legs" class="hp-oo-legs">
<div class="hp-oo-leg-row" data-leg="a">
<div class="muted" id="hp-oo-leg-a-info">腿A: 尚未选用</div>
<label>张数 <span class="hp-unit">期权张</span>
<input type="number" step="1" min="0" id="hp-oo-sheets-a" value="1" disabled autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
</div>
<div class="hp-oo-leg-row" data-leg="b">
<div class="muted" id="hp-oo-leg-b-info">腿B: 尚未选用</div>
<label>张数 <span class="hp-unit">期权张</span>
<input type="number" step="1" min="0" id="hp-oo-sheets-b" value="1" disabled autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
</div>
<p class="muted" id="hp-oo-prem-line"></p>
</div>
</div>
<div class="card hp-opt-card">
<h2>期权 T 型报价</h2>
<div class="form-row">
<select id="hp-oo-exp-select"><option value="">选择到期日</option></select>
<button type="button" class="btn-secondary hp-oo-money-btn is-selected active" data-oo-money="atm_otm" title="平值+虚值" aria-pressed="true"><span class="hp-oo-check" aria-hidden="true">✓</span>平/虚</button>
<button type="button" class="btn-secondary hp-oo-money-btn" data-oo-money="atm" title="仅平值" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>仅平值</button>
<button type="button" class="btn-secondary hp-oo-money-btn" data-oo-money="otm" title="仅虚值" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>仅虚值</button>
<button type="button" class="btn-secondary hp-oo-recommend-btn" id="hp-oo-recommend-atm" data-oo-rec="atm_straddle" title="最近平值 Call+Put" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>推荐跨式</button>
<button type="button" class="btn-secondary hp-oo-recommend-btn" id="hp-oo-recommend-otm" data-oo-rec="double_otm" title="最近虚值 Call+Put" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>推荐双虚</button>
<button type="button" class="btn-secondary" id="hp-oo-load-chain">刷新链</button>
<button type="button" class="btn-secondary hp-oo-expand-btn" id="hp-oo-expand-all" title="展开该到期全部平值/虚值行权价;若当前为「仅平值」会自动切到「平/虚」" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>显示全部</button>
</div>
<div class="options-strike-table-wrap hp-oo-table-wrap" id="hp-oo-table-wrap">
<table class="options-strike-table options-strike-table--t" id="hp-oo-table">
<thead>
<tr>
<th colspan="4" class="opt-t-head-call">Call</th>
<th class="opt-t-head-mid">行权</th>
<th colspan="4" class="opt-t-head-put">Put</th>
</tr>
<tr>
<th>卖一/张</th><th title="行权价÷卖一">杠杆</th><th>实虚值</th><th>选用</th>
<th>K</th>
<th>实虚值</th><th>卖一/张</th><th title="行权价÷卖一">杠杆</th><th>选用</th>
</tr>
</thead>
<tbody id="hp-oo-tbody">
<tr><td colspan="9" class="muted">请刷新期权链</td></tr>
</tbody>
</table>
</div>
<div class="hp-oo-transfer hp-oo-transfer--compact" id="hp-oo-transfer">
<div class="hp-oo-transfer-bals muted">
<span>资金 <strong id="hp-oo-funding-usdc">—</strong></span>
<span class="hp-oo-transfer-sep">·</span>
<span>交易 <strong id="hp-oo-trading-usdc">—</strong></span>
<span class="hp-oo-transfer-unit">USDT</span>
<span class="muted" id="hp-oo-xfer-msg"></span>
</div>
<div class="form-row hp-oo-transfer-form" autocomplete="off">
{# 诱饵账号框:避免浏览器把划转数量当成登录用户名填 dekun #}
<input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0" value="">
<select id="hp-oo-xfer-dir" aria-label="划转方向" autocomplete="off">
<option value="funding_to_trading" selected>资金 → 交易</option>
<option value="trading_to_funding">交易 → 资金</option>
</select>
<input type="number" id="hp-oo-xfer-amount" name="cm_hp_xfer_amt" min="0.01" step="0.01" placeholder="数量"
autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-bwignore="true" data-form-type="other" readonly />
<button type="button" class="btn-secondary btn-sm" id="hp-oo-xfer-all">全部</button>
<button type="button" class="btn-primary btn-sm" id="hp-oo-xfer-btn">划转</button>
</div>
</div>
<div class="form-row hp-action-row">
<button type="button" class="primary" id="hp-preview-btn-oo">计算</button>
</div>
</div>
</div>
</div>
<div id="hp-detail-modal" class="hp-modal-backdrop" hidden>
<div class="hp-modal" role="dialog" aria-modal="true" aria-labelledby="hp-detail-title">
<div class="hp-modal-head">
<h3 id="hp-detail-title">成交细节</h3>
<button type="button" class="btn-secondary" id="hp-detail-close">关闭</button>
</div>
<div id="hp-detail-body" class="hp-modal-body muted">加载中…</div>
</div>
</div>
<div id="hp-preview-modal" class="hp-modal-backdrop" hidden>
<div class="hp-modal hp-preview-modal" role="dialog" aria-modal="true" aria-labelledby="hp-preview-title">
<div class="hp-modal-head">
<h3 id="hp-preview-title">情景测算</h3>
<button type="button" class="btn-secondary" id="hp-preview-cancel-x" aria-label="关闭">关闭</button>
</div>
<div id="hp-preview-summary" class="muted hp-preview-summary"></div>
<div class="options-strike-table-wrap">
<table class="options-strike-table" id="hp-result-table">
<thead>
<tr>
<th>情景</th>
<th>现货价</th>
<th id="hp-preview-mid-th">永续/腿盈亏</th>
<th>期权盈亏</th>
<th>合计≈U</th>
<th>说明</th>
</tr>
</thead>
<tbody id="hp-result-tbody">
<tr><td colspan="6" class="muted">计算中…</td></tr>
</tbody>
</table>
</div>
<div class="form-row hp-preview-actions">
<button type="button" class="btn-secondary" id="hp-preview-cancel">取消</button>
<button type="button" class="primary" id="hp-preview-start" disabled title="需开启 HEDGE_PLAN_LIVE_ORDER 等门禁">启动计划</button>
</div>
</div>
</div>
<div id="hp-exit-modal" class="hp-modal-backdrop" hidden>
<div class="hp-modal hp-exit-modal" role="dialog" aria-modal="true" aria-labelledby="hp-exit-title">
<div class="hp-modal-head">
<h3 id="hp-exit-title">改出场</h3>
<button type="button" class="btn-secondary" id="hp-exit-close" aria-label="关闭">关闭</button>
</div>
<div class="hp-modal-body">
<input type="hidden" id="hp-exit-plan-id" value="" />
<div class="hp-oo-seg hp-exit-mode-seg" role="group" aria-label="出场方式">
<button type="button" class="btn-secondary hp-exit-mode-btn is-selected" data-exit="profit"><span class="hp-oo-check" aria-hidden="true">✓</span>盈利金额</button>
<button type="button" class="btn-secondary hp-exit-mode-btn" data-exit="target"><span class="hp-oo-check" aria-hidden="true">✓</span>目标位</button>
</div>
<div class="hp-exit-fields" id="hp-exit-fields-profit">
<label>目标盈利 USDT
<input type="number" id="hp-exit-profit" step="0.01" min="0.01" inputmode="decimal" />
</label>
<p class="muted">扣开平双边手续费后的组合净利达标即平(期权买一+永续盘口均价).</p>
</div>
<div class="hp-exit-fields hidden" id="hp-exit-fields-target" hidden>
<label>期权目标点数
<input type="number" id="hp-exit-opt-pts" step="1" min="1" inputmode="numeric" />
</label>
<label>永续目标点数
<input type="number" id="hp-exit-perp-pts" step="1" min="1" inputmode="numeric" />
</label>
</div>
<p class="err" id="hp-exit-err" hidden></p>
<div class="form-row hp-preview-actions">
<button type="button" class="btn-secondary" id="hp-exit-cancel">取消</button>
<button type="button" class="primary" id="hp-exit-save">保存</button>
</div>
</div>
</div>
</div>
</div>
<script src="/static/hedge_plan.js?v=70"></script>