Allow entering sheet counts for each options-options hedge leg.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -494,26 +494,64 @@
|
||||
}
|
||||
|
||||
function renderOoLegs() {
|
||||
const el = $("hp-oo-legs");
|
||||
if (!el) return;
|
||||
function one(tag, c) {
|
||||
if (!c) return tag + ": —";
|
||||
return (
|
||||
function fill(tag, c, infoId, sheetsId) {
|
||||
const info = $(infoId);
|
||||
const sheets = $(sheetsId);
|
||||
if (!info) return;
|
||||
if (!c) {
|
||||
info.textContent = tag + ": 尚未选用";
|
||||
if (sheets) {
|
||||
sheets.disabled = true;
|
||||
sheets.value = "1";
|
||||
}
|
||||
return;
|
||||
}
|
||||
info.innerHTML =
|
||||
tag +
|
||||
": " +
|
||||
": <strong>" +
|
||||
c.opt_type +
|
||||
" K" +
|
||||
c.strike +
|
||||
" " +
|
||||
"</strong> " +
|
||||
(c.moneyness_label || "") +
|
||||
" ask=" +
|
||||
" · 卖一 " +
|
||||
fmtPxSz(c.ask, c.ask_sz, c.ask_estimated, c.tick_sz) +
|
||||
" (" +
|
||||
" <code>" +
|
||||
c.inst_id +
|
||||
")"
|
||||
);
|
||||
"</code>";
|
||||
if (sheets) sheets.disabled = false;
|
||||
}
|
||||
el.innerHTML = one("腿A", state.legA) + "<br/>" + one("腿B", state.legB);
|
||||
fill("腿A", state.legA, "hp-oo-leg-a-info", "hp-oo-sheets-a");
|
||||
fill("腿B", state.legB, "hp-oo-leg-b-info", "hp-oo-sheets-b");
|
||||
updateOoPremiumLine();
|
||||
}
|
||||
|
||||
function ooSheets(id) {
|
||||
const n = Number(($(id) && $(id).value) || 1);
|
||||
return n > 0 ? n : 1;
|
||||
}
|
||||
|
||||
function updateOoPremiumLine() {
|
||||
const line = $("hp-oo-prem-line");
|
||||
if (!line) return;
|
||||
if (!state.legA && !state.legB) {
|
||||
line.textContent = "";
|
||||
return;
|
||||
}
|
||||
function prem(c, sheets) {
|
||||
if (!c) return 0;
|
||||
return Number(c.ask || 0) * sheets * Number(c.ct_mult || 0.01);
|
||||
}
|
||||
const a = prem(state.legA, ooSheets("hp-oo-sheets-a"));
|
||||
const b = prem(state.legB, ooSheets("hp-oo-sheets-b"));
|
||||
line.textContent =
|
||||
"预估权利金 A " +
|
||||
fmt(a, 4) +
|
||||
" + B " +
|
||||
fmt(b, 4) +
|
||||
" ≈ " +
|
||||
fmt(a + b, 4) +
|
||||
" USDC";
|
||||
}
|
||||
|
||||
function legPayload(c, sheets) {
|
||||
@@ -543,7 +581,15 @@
|
||||
if ($("hp-target")) $("hp-target").value = "";
|
||||
if ($("hp-sel-inst")) $("hp-sel-inst").textContent = "—";
|
||||
if ($("hp-premium-line")) $("hp-premium-line").textContent = "";
|
||||
if ($("hp-oo-legs")) $("hp-oo-legs").textContent = "尚未选用两腿";
|
||||
if ($("hp-oo-sheets-a")) {
|
||||
$("hp-oo-sheets-a").value = "1";
|
||||
$("hp-oo-sheets-a").disabled = true;
|
||||
}
|
||||
if ($("hp-oo-sheets-b")) {
|
||||
$("hp-oo-sheets-b").value = "1";
|
||||
$("hp-oo-sheets-b").disabled = true;
|
||||
}
|
||||
renderOoLegs();
|
||||
void refreshAll();
|
||||
}
|
||||
|
||||
@@ -561,8 +607,8 @@
|
||||
plan_type: "options_options",
|
||||
target_price: target,
|
||||
index_px: (state.chain && state.chain.index_px) || target,
|
||||
leg_a: legPayload(state.legA, 1),
|
||||
leg_b: legPayload(state.legB, 1),
|
||||
leg_a: legPayload(state.legA, ooSheets("hp-oo-sheets-a")),
|
||||
leg_b: legPayload(state.legB, ooSheets("hp-oo-sheets-b")),
|
||||
};
|
||||
} else {
|
||||
if (!state.selected) throw new Error("请选用期权腿");
|
||||
@@ -708,6 +754,10 @@
|
||||
if ($("hp-exp-select")) $("hp-exp-select").addEventListener("change", renderListStrikes);
|
||||
if ($("hp-oo-exp-select")) $("hp-oo-exp-select").addEventListener("change", renderTStrikes);
|
||||
if ($("hp-sheets")) $("hp-sheets").addEventListener("input", updatePremiumLine);
|
||||
["hp-oo-sheets-a", "hp-oo-sheets-b"].forEach(function (id) {
|
||||
const el = $(id);
|
||||
if (el) el.addEventListener("input", updateOoPremiumLine);
|
||||
});
|
||||
if ($("hp-preview-btn"))
|
||||
$("hp-preview-btn").addEventListener("click", function () {
|
||||
state.mode = "perp_options";
|
||||
|
||||
@@ -3234,6 +3234,26 @@ html[data-theme="light"] .opt-be-dist-down {
|
||||
.hedge-plan-page-wrap .hp-pnl-neg {
|
||||
color: #ff8a8a;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-legs {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-leg-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-leg-row input[type="number"] {
|
||||
width: 72px;
|
||||
}
|
||||
.hedge-plan-page-wrap .form-row label,
|
||||
.hedge-plan-page-wrap .form-row select,
|
||||
.hedge-plan-page-wrap .form-row input,
|
||||
|
||||
@@ -124,7 +124,22 @@
|
||||
</div>
|
||||
<div id="hp-oo-index" class="muted hp-quote-line"></div>
|
||||
<div id="hp-oo-bal-line" class="muted hp-quote-line"></div>
|
||||
<div id="hp-oo-legs" class="muted" style="margin-top:8px;line-height:1.6">尚未选用两腿</div>
|
||||
<p class="muted hp-unit-hint">单位说明:目标价=指数价(USD) · 张数=<strong>期权张</strong>(整张) · 权利金结算币=USDC</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="1" id="hp-oo-sheets-a" value="1" disabled />
|
||||
</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="1" id="hp-oo-sheets-b" value="1" disabled />
|
||||
</label>
|
||||
</div>
|
||||
<p class="muted" id="hp-oo-prem-line"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>期权 T 型报价</h2>
|
||||
@@ -195,4 +210,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/hedge_plan.js?v=7"></script>
|
||||
<script src="/static/hedge_plan.js?v=8"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="/static/instance_theme_early.css?v=4">
|
||||
<link rel="stylesheet" href="/static/account_risk_badge.css?v=4">
|
||||
<link rel="stylesheet" href="/static/instance_page.css?v=6">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=86">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=87">
|
||||
<script src="/static/account_risk_badge.js?v=4"></script>
|
||||
<meta name="theme-color" content="#0b0d14">
|
||||
<title>{{ exchange_display }} · 加密货币 | 交易监控复盘系统</title>
|
||||
|
||||
@@ -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=3">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=86">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=87">
|
||||
|
||||
</head>
|
||||
<body
|
||||
|
||||
Reference in New Issue
Block a user