fix(hedge): show option list by interval; leverage only at start
Keep capital/select params on one row, reload chain when interval changes, and stop filtering the chain by option leverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -149,31 +149,17 @@
|
||||
return fmt(v, 2) + ":1";
|
||||
}
|
||||
|
||||
function optionPrimaryLevOk(c, moneyKind) {
|
||||
const idx = indexPx();
|
||||
const ask = Number(c && c.ask);
|
||||
if (!(idx > 0) || !(ask > 0)) return true;
|
||||
const kind = moneyKind || opMoneyKind();
|
||||
// 方案:杠杆门主要卡虚值;实/平列表不过滤,选用/启动再校验
|
||||
if (kind !== "otm") return true;
|
||||
const minLev = numInput("hp-opt-leverage", 200);
|
||||
const levFloor = Math.max(minLev, 180);
|
||||
return idx / ask >= levFloor;
|
||||
}
|
||||
|
||||
function matchesMoneyFilter(c) {
|
||||
const f = state.moneyFilter || "itm";
|
||||
const m = (c.moneyness || "").toLowerCase();
|
||||
if (!isOptionPrimary() && f === "otm") return false;
|
||||
// 列表只按间隔+虚实值;期权杠杆仅启动/计算时由后端校验
|
||||
if (isOptionPrimary()) {
|
||||
const idx = indexPx();
|
||||
const interval = numInput("hp-strike-interval", 15);
|
||||
if (idx && interval > 0 && Math.abs(Number(c.strike) - idx) > interval + 1e-9) {
|
||||
return false;
|
||||
}
|
||||
if (!optionPrimaryLevOk(c, f === "otm" ? "otm" : f === "atm" ? "atm" : "itm")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (f === "itm") return m === "itm" || m === "atm";
|
||||
if (f === "atm") return m === "atm";
|
||||
@@ -441,7 +427,7 @@
|
||||
updatePerpPnlHint();
|
||||
}
|
||||
|
||||
/** 以期权为主:按类型/间隔/杠杆自动匹配最近合约. */
|
||||
/** 以期权为主:按类型/间隔自动匹配最近合约. */
|
||||
function autoMatchPoOption(force) {
|
||||
if (!isOptionPrimary()) return;
|
||||
const want = optTypeForDirection(getDirection());
|
||||
@@ -1111,7 +1097,7 @@
|
||||
return;
|
||||
}
|
||||
if (isOptionPrimary() && !matchesMoneyFilter(c)) {
|
||||
alert("不符合当前间隔/杠杆/虚实值过滤");
|
||||
alert("不符合当前间隔/虚实值过滤");
|
||||
return;
|
||||
}
|
||||
state.selected = c;
|
||||
@@ -1163,8 +1149,7 @@
|
||||
sameType.length +
|
||||
" 档)·检查间隔" +
|
||||
(interval != null ? "≤" + interval : "") +
|
||||
"点/虚实值" +
|
||||
(state.moneyFilter === "otm" ? "/虚值杠杆门" : "");
|
||||
"点/虚实值";
|
||||
} else if (!sameType.length) {
|
||||
hint =
|
||||
"该到期无 " +
|
||||
@@ -1759,7 +1744,6 @@
|
||||
if ($("hp-opt-leverage")) {
|
||||
$("hp-opt-leverage").addEventListener("input", function () {
|
||||
state.opLevTouched = true;
|
||||
renderListStrikes();
|
||||
});
|
||||
}
|
||||
if ($("hp-opt-perp-ratio")) {
|
||||
@@ -1772,14 +1756,24 @@
|
||||
void loadMarket();
|
||||
});
|
||||
}
|
||||
let _poChainReloadTimer = null;
|
||||
function schedulePoChainReload() {
|
||||
if (_poChainReloadTimer) clearTimeout(_poChainReloadTimer);
|
||||
_poChainReloadTimer = setTimeout(function () {
|
||||
_poChainReloadTimer = null;
|
||||
void loadChain();
|
||||
}, 350);
|
||||
}
|
||||
["hp-premium-budget", "hp-strike-interval", "hp-min-hours", "hp-opt-target-pts", "hp-perp-target-pts"].forEach(
|
||||
function (id) {
|
||||
const el = $(id);
|
||||
if (!el) return;
|
||||
el.addEventListener("input", function () {
|
||||
if (id === "hp-min-hours" && state.chain) fillExpSelect($("hp-exp-select"), state.chain);
|
||||
if (id === "hp-strike-interval" || id === "hp-premium-budget") renderListStrikes();
|
||||
if (state.selected && (id === "hp-premium-budget" || id === "hp-strike-interval")) {
|
||||
if (id === "hp-min-hours" || id === "hp-strike-interval") {
|
||||
schedulePoChainReload();
|
||||
}
|
||||
if (id === "hp-premium-budget") renderListStrikes();
|
||||
if (state.selected && id === "hp-premium-budget") {
|
||||
const sized = computeOpSizing(state.selected.ask, state.selected.ct_mult || 0.01);
|
||||
if (sized && $("hp-sheets")) $("hp-sheets").value = String(sized.sheets);
|
||||
void loadMarket();
|
||||
@@ -1805,7 +1799,7 @@
|
||||
if (isOptionPrimary()) {
|
||||
autoMatchPoOption(true);
|
||||
if (!state.selected) {
|
||||
alert("当前选约条件下无匹配合约,请调整类型/间隔/杠杆或换到期");
|
||||
alert("当前选约条件下无匹配合约,请调整类型/间隔或换到期");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3511,13 +3511,38 @@ html[data-theme="light"] .opt-be-dist-down {
|
||||
.hedge-plan-page-wrap .hp-po-fields--section {
|
||||
margin: 0;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-fields--capital {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-fields--select {
|
||||
grid-template-columns: minmax(72px, 0.9fr) minmax(72px, 0.9fr) minmax(0, 1.6fr) minmax(72px, 0.9fr);
|
||||
align-items: end;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-field--type {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-type-seg {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
flex-wrap: nowrap;
|
||||
gap: 4px;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-type-seg .hp-money-btn {
|
||||
flex: 1 1 0;
|
||||
padding: 4px 6px;
|
||||
font-size: 0.72rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.hedge-plan-page-wrap .hp-po-fields--capital,
|
||||
.hedge-plan-page-wrap .hp-po-fields--select {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-field--type {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-type-seg {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-po-right-stack {
|
||||
display: flex;
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<div id="hp-po-fields-option-primary">
|
||||
<section class="hp-po-section" aria-labelledby="hp-po-sec-capital">
|
||||
<h3 id="hp-po-sec-capital" class="hp-po-section-title">资金与杠杆配置</h3>
|
||||
<div class="hp-po-fields hp-po-fields--section">
|
||||
<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>USDC</em></span>
|
||||
<input type="number" step="any" id="hp-premium-budget" placeholder="预算(执行×0.95)" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
|
||||
@@ -100,14 +100,14 @@
|
||||
<input type="number" step="1" id="hp-perp-leverage" value="100" 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">期权杠杆</span>
|
||||
<span class="hp-po-field-lab">期权杠杆 <em>启动校验</em></span>
|
||||
<input type="number" step="1" id="hp-opt-leverage" value="100" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
<section class="hp-po-section" aria-labelledby="hp-po-sec-select">
|
||||
<h3 id="hp-po-sec-select" class="hp-po-section-title">选约条件</h3>
|
||||
<div class="hp-po-fields hp-po-fields--section">
|
||||
<div class="hp-po-fields hp-po-fields--section hp-po-fields--select">
|
||||
<label class="hp-po-field">
|
||||
<span class="hp-po-field-lab">到期时间 <em>最短h</em></span>
|
||||
<input type="number" step="1" id="hp-min-hours" value="36" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
|
||||
@@ -119,8 +119,8 @@
|
||||
<div class="hp-po-field hp-po-field--type">
|
||||
<span class="hp-po-field-lab">类型</span>
|
||||
<div class="hp-oo-seg hp-po-type-seg" role="group" aria-label="虚实值类型">
|
||||
<button type="button" class="btn-secondary hp-money-btn active" data-money="itm" title="实值+平值"><span class="hp-oo-check" aria-hidden="true">✓</span>实值/平值</button>
|
||||
<button type="button" class="btn-secondary hp-money-btn" data-money="atm" title="仅平值"><span class="hp-oo-check" aria-hidden="true">✓</span>仅平值</button>
|
||||
<button type="button" class="btn-secondary hp-money-btn active" data-money="itm" title="实值+平值"><span class="hp-oo-check" aria-hidden="true">✓</span>实/平</button>
|
||||
<button type="button" class="btn-secondary hp-money-btn" data-money="atm" title="仅平值"><span class="hp-oo-check" aria-hidden="true">✓</span>平值</button>
|
||||
<button type="button" class="btn-secondary hp-money-btn hp-money-otm" data-money="otm" title="虚值"><span class="hp-oo-check" aria-hidden="true">✓</span>虚值</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -403,4 +403,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/hedge_plan.js?v=41"></script>
|
||||
<script src="/static/hedge_plan.js?v=42"></script>
|
||||
|
||||
Reference in New Issue
Block a user