Show OKX option Delta on hedge plan strike picker.
Surface ticker delta (gamma in tooltip) in the chain table and selected premium line for easier ITM selection. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -894,6 +894,14 @@
|
||||
}
|
||||
|
||||
/** CoinOX 币本位:卖一为币报价 → 杠杆≈1÷卖一(与期权页一致). */
|
||||
function fmtDelta(v) {
|
||||
const n = Number(v);
|
||||
if (v == null || Number.isNaN(n)) return "—";
|
||||
// Call 多为正,Put 多为负;保留两位便于对比实虚值
|
||||
const s = fmt(n, 2);
|
||||
return n > 0 ? "+" + s : s;
|
||||
}
|
||||
|
||||
function calcIndexAskLeverage(ask) {
|
||||
const a = Number(ask);
|
||||
if (!(a > 0)) return "—";
|
||||
@@ -2262,7 +2270,7 @@
|
||||
const want = optTypeForDirection(getDirection());
|
||||
const exp = currentExp("hp-exp-select");
|
||||
const prevInst = state.selected && state.selected.inst_id;
|
||||
const cols = isOptionPrimary() ? 7 : 6;
|
||||
const cols = isOptionPrimary() ? 8 : 7;
|
||||
tbody.innerHTML = "";
|
||||
if (!exp) {
|
||||
tbody.innerHTML = '<tr><td colspan="' + cols + '" class="muted">请选择到期日</td></tr>';
|
||||
@@ -2302,13 +2310,21 @@
|
||||
tr.className = "opt-strike-row" + (c.moneyness ? " opt-row-" + c.moneyness : "");
|
||||
if (prevInst && c.inst_id === prevInst) tr.classList.add("opt-row-selected");
|
||||
tr.setAttribute("data-inst", c.inst_id);
|
||||
const deltaCell =
|
||||
'<td class="opt-chain-delta" title="交易所 Delta' +
|
||||
(c.gamma != null ? " · γ=" + fmt(c.gamma, 4) : "") +
|
||||
'">' +
|
||||
fmtDelta(c.delta) +
|
||||
"</td>";
|
||||
if (isOptionPrimary()) {
|
||||
tr.innerHTML =
|
||||
"<td>" +
|
||||
c.strike +
|
||||
"</td><td>" +
|
||||
moneynessBadge(c) +
|
||||
"</td><td><code class=\"opt-inst-code\">" +
|
||||
"</td>" +
|
||||
deltaCell +
|
||||
'<td><code class="opt-inst-code">' +
|
||||
(c.inst_id || "") +
|
||||
'</code></td><td class="opt-px-sz">' +
|
||||
fmtPxSz(c.ask, c.ask_sz, c.ask_estimated, c.tick_sz) +
|
||||
@@ -2327,7 +2343,9 @@
|
||||
c.strike +
|
||||
"</td><td>" +
|
||||
moneynessBadge(c) +
|
||||
'</td><td class="opt-chain-lev" title="指数÷卖一">' +
|
||||
"</td>" +
|
||||
deltaCell +
|
||||
'<td class="opt-chain-lev" title="指数÷卖一">' +
|
||||
calcIndexAskLeverage(c.ask) +
|
||||
'</td><td class="opt-px-sz">' +
|
||||
fmtPxSz(c.ask, c.ask_sz, c.ask_estimated, c.tick_sz) +
|
||||
@@ -2366,6 +2384,7 @@
|
||||
// U 以期权标的指数为准(买 BTC/ETH 开期权);跨币不可用永续 ETH 价
|
||||
const buyPx = Number(optionIndexPx() || 0);
|
||||
const premU = buyPx > 0 ? prem * buyPx : null;
|
||||
const dlt = state.selected.delta;
|
||||
line.textContent =
|
||||
"权利金 ≈ " +
|
||||
fmt(prem, 4) +
|
||||
@@ -2374,7 +2393,8 @@
|
||||
(premU != null ? " / " + fmt(premU, 2) + " U" : "") +
|
||||
" · 卖一 " +
|
||||
fmt(ask, 4) +
|
||||
(buyPx > 0 ? " · 买" + optionCoin() + "参考 " + fmt(buyPx, 2) : "");
|
||||
(buyPx > 0 ? " · 买" + optionCoin() + "参考 " + fmt(buyPx, 2) : "") +
|
||||
(dlt != null && !Number.isNaN(Number(dlt)) ? " · Δ " + fmtDelta(dlt) : "");
|
||||
}
|
||||
|
||||
function buildStraddleRows(contracts) {
|
||||
|
||||
@@ -285,6 +285,9 @@ def _resolve_chain_quote(
|
||||
if ask_estimated:
|
||||
ask_sz = None
|
||||
|
||||
# OKX 期权 ticker 自带希腊字母(选约用);缺省时前端显示 —
|
||||
delta = _safe_float(ticker.get("delta") or ticker.get("deltaBS"))
|
||||
gamma = _safe_float(ticker.get("gamma") or ticker.get("gammaBS"))
|
||||
return {
|
||||
"ask": ask,
|
||||
"bid": bid,
|
||||
@@ -292,6 +295,8 @@ def _resolve_chain_quote(
|
||||
"bid_sz": bid_sz,
|
||||
"mark_px": mark,
|
||||
"ask_estimated": ask_estimated,
|
||||
"delta": delta,
|
||||
"gamma": gamma,
|
||||
}
|
||||
|
||||
|
||||
@@ -945,6 +950,8 @@ def build_option_chain(
|
||||
"bid_sz": bid_sz,
|
||||
"mark_px": mark,
|
||||
"ask_estimated": q["ask_estimated"],
|
||||
"delta": q.get("delta"),
|
||||
"gamma": q.get("gamma"),
|
||||
"expiry_be_px": expiry_be,
|
||||
"dist_expiry_be": strike_distance_to_be(strike, expiry_be, opt_type=opt_type),
|
||||
"moneyness": mny,
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
<tr>
|
||||
<th>行权价</th>
|
||||
<th>类型</th>
|
||||
<th title="交易所 Delta:标的变动时期权价敏感度;实值 |Δ| 通常更大(Call为正/Put为负)">Delta</th>
|
||||
<th>合约</th>
|
||||
<th>卖一/张</th>
|
||||
<th title="币本位:1÷卖一">杠杆</th>
|
||||
@@ -110,7 +111,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="hp-strike-tbody">
|
||||
<tr><td colspan="7" class="muted">请刷新期权链</td></tr>
|
||||
<tr><td colspan="8" class="muted">请刷新期权链</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -508,4 +509,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/hedge_plan.js?v=68"></script>
|
||||
<script src="/static/hedge_plan.js?v=69"></script>
|
||||
|
||||
Reference in New Issue
Block a user