Anchor semi exit to strike +/- move points; side-by-side semi cards.

Forward target is K+/-N not spot+/-N; UI shows option target and perp net lock.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-08 14:59:48 +08:00
parent 6f983ed2ab
commit 4f56eff40c
8 changed files with 162 additions and 70 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ const CLOSE_REASON_ZH: Record<string, string> = {
premium_multiple: "权利金倍数达标·双腿全平",
target_perp_only: "净盈利达标·只平永续(期权归档)",
residual_premium_close: "残留期权·权利金回收中途平",
semi_target_points: "半自动·标的到点且组合净利>0·双腿全平",
semi_perp_exit: "半自动·净利基数达标·双腿全平",
semi_target_points: "半自动·指数到行权价±波动点且净利>0·双腿全平",
semi_perp_exit: "半自动·永续净利锁定达标·双腿全平",
expiry: "到期结算",
emergency: "紧急全平",
manual: "手动平仓",
+68 -38
View File
@@ -226,8 +226,8 @@ function estimateSemiRiskQty(args: {
}
/**
* 标的顺向波动 move 点后的组合盈亏粗估(期权用内在价值变化,永续按点位)
* 多=Call+永续空;空=Put+永续多。不含权利金时间价值/IV
* 指数走到「行权价 ± 波动点」时的组合盈亏粗估
* 多=Call 目标 K+N;空=Put 目标 KN。不含 IV/时间价值。
*/
function estimateSemiMoveProfit(args: {
view: "long" | "short";
@@ -263,16 +263,17 @@ function estimateSemiMoveProfit(args: {
if (!(S > 0) || !(K > 0) || !(move > 0) || !(oq > 0) || !(pq > 0)) {
return { ok: false, detail: "缺指数/行权价/数量" };
}
const tgt = view === "long" ? S + move : S - move;
const tgt = view === "long" ? K + move : K - move;
const dSpot = tgt - S;
const callIntr = (px: number) => Math.max(0, px - K);
const putIntr = (px: number) => Math.max(0, K - px);
const dIntr =
view === "long"
? callIntr(tgt) - callIntr(S)
: putIntr(tgt) - putIntr(S);
// 多:空永续随涨亏;空:多永续随跌亏 → 均为 -move×qty
const optionPnl = dIntr * oq;
const perpPnl = -move * pq;
// 多:空永续;空:多永续 → 指数变化 dSpot 时永续盈亏 = dSpot×qty
const perpPnl = -dSpot * pq;
const fees =
feeRate > 0 ? S * feeRate * 3 * Math.max(oq, pq) /* 粗估开平 */ : 0;
const net = optionPnl + perpPnl - fees;
@@ -566,23 +567,50 @@ export default function PlanPage() {
const movePct = pos?.move_pct ?? 0;
const ooRatio = Number(plan?.oo_reward_ratio ?? 2);
const ooBudget = plan?.risk_sizing_preview?.budget;
const exitRuleLabel = isOo
? exitTarget != null
? `${riskLocked ? "锁定 " : ""}净盈≥${fmt(exitTarget)} U${
ooBudget != null ? `${fmt(ooBudget)}×` : "预算×"
}${fmt(ooRatio, 1)}`
: `净盈≥预算×${fmt(ooRatio, 1)}(达标只平盈利腿)`
: exitMode === "premium_multiple"
? riskBased
? exitTarget != null
? `${riskLocked ? "锁定 " : ""}净盈≥${fmt(exitTarget)} U(权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}`
: `权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}(开仓后锁定)`
: `权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}`
: riskBased
? exitTarget != null
? `${riskLocked ? "锁定 " : "固定 "}${fmt(exitTarget)} U(基数${fmt(plan?.risk_exit_unit ?? 15)}`
: `待估算(基数${fmt(plan?.risk_exit_unit ?? 15)}`
: `固定 ${fmt(plan?.net_profit_target ?? 15)} U`;
const semiExitMove = Number(semiMove) || 50;
const semiExitView: "long" | "short" =
(semiDirty ? semiView : plan?.semi_view_side === "short" ? "short" : "long") ===
"short"
? "short"
: "long";
const semiExitStrike =
open && pos?.strike != null && Number.isFinite(Number(pos.strike))
? Number(pos.strike)
: null;
const semiOptTarget =
semiExitStrike != null
? semiExitView === "short"
? semiExitStrike - semiExitMove
: semiExitStrike + semiExitMove
: null;
const semiNetLock = Number(
plan?.semi_net_exit_target ??
(riskBased
? Number(semiExitU) *
Number(plan?.risk_last_k ?? plan?.risk_sizing_preview?.k ?? 1)
: semiExitU),
);
const exitRuleLabel = semiOn
? semiOptTarget != null
? `期权目标 K${Math.round(semiExitStrike!)}${fmtExPx("index", semiOptTarget)} · 永续净利锁定≥${fmt(semiNetLock, 2)}U`
: `期权目标 行权价${semiExitView === "short" ? "" : "+"}${fmt(semiExitMove, 0)} · 永续净利锁定≥${fmt(semiNetLock, 2)}U`
: isOo
? exitTarget != null
? `${riskLocked ? "锁定 " : ""}净盈≥${fmt(exitTarget)} U${
ooBudget != null ? `${fmt(ooBudget)}×` : "预算×"
}${fmt(ooRatio, 1)}`
: `净盈≥预算×${fmt(ooRatio, 1)}(达标只平盈利腿)`
: exitMode === "premium_multiple"
? riskBased
? exitTarget != null
? `${riskLocked ? "锁定 " : ""}净盈≥${fmt(exitTarget)} U(权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}`
: `权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}(开仓后锁定)`
: `权利金×${fmt(plan?.premium_exit_multiple ?? 1, 2)}`
: riskBased
? exitTarget != null
? `${riskLocked ? "锁定 " : "固定 "}${fmt(exitTarget)} U(基数${fmt(plan?.risk_exit_unit ?? 15)}`
: `待估算(基数${fmt(plan?.risk_exit_unit ?? 15)}`
: `固定 ${fmt(plan?.net_profit_target ?? 15)} U`;
const riskRatioLabel = isOo
? "预算平分 Call/Put"
: `比例${Number(plan?.risk_perp_unit ?? 1)}:${Number(plan?.risk_option_unit ?? 2)}`;
@@ -887,9 +915,9 @@ export default function PlanPage() {
<li>永续:期权配比与出场 //</li>
<li></li>
<li> 180 200/</li>
<li> N / + </li>
<li> ± &gt; 0 </li>
<li> × k </li>
<li> N = ± N CallK+N PutKN±N</li>
<li> &gt; 0 </li>
<li> × k </li>
<li> k</li>
</ul>
</details>
@@ -981,7 +1009,7 @@ export default function PlanPage() {
/>
</div>
<div className="field">
<label htmlFor="semiMove">()</label>
<label htmlFor="semiMove">(K)</label>
<input
id="semiMove"
className="mono"
@@ -1121,15 +1149,15 @@ export default function PlanPage() {
: semiExitU),
);
if (idx == null || !Number.isFinite(idx)) {
return `逆向兑现≥${fmt(reverseTgt, 2)}U`;
}
if (strike == null || !Number.isFinite(strike)) {
return `期权目标 行权价${semiView === "short" ? "" : "+"}${fmt(Number(semiMove) || 50, 0)} · 永续锁定≥${fmt(reverseTgt, 2)}U`;
}
if (idx == null || !Number.isFinite(idx)) {
const tgt =
semiView === "long"
? idx + Number(semiMove)
: idx - Number(semiMove);
return `${fmtExPx("index", idx)}${fmtExPx("index", tgt)} · 待行权价估盈利 · 逆向${fmt(reverseTgt, 2)}U`;
? strike + Number(semiMove)
: strike - Number(semiMove);
return `期权目标 K${Math.round(strike)}${fmtExPx("index", tgt)} · 永续锁定${fmt(reverseTgt, 2)}U`;
}
const prof = estimateSemiMoveProfit({
@@ -1139,22 +1167,23 @@ export default function PlanPage() {
movePoints: Number(semiMove) || 50,
optionQty: optQty,
perpQty: perpQty,
feeRate: 0, // 预估展示用内在+永续点位;手续费另计
feeRate: 0,
});
if (!prof.ok) {
return prof.detail;
}
return (
<>
{fmtExPx("index", idx)}{fmtExPx("index", prof.targetPx!)} ·
K{Math.round(strike)} · {fmt(prof.netEst, 2)}U
K{Math.round(strike)}
{fmtExPx("index", prof.targetPx!)} ·
{fmtExPx("index", idx)} · {fmt(prof.netEst, 2)}U
<span className="meta">
{" "}
({fmt(prof.optionPnl, 1)}/
{fmt(prof.perpPnl, 1)} · )
{fmt(prof.perpPnl, 1)})
</span>
{" · "}
{fmt(reverseTgt, 2)}U
{fmt(reverseTgt, 2)}U
</>
);
})()}
@@ -1437,7 +1466,8 @@ export default function PlanPage() {
? ` · 虚值≤${fmt(semiOtmOff, 0)}`
: ""}
{" · "}
±{fmt(semiMove, 0)}&gt;0 /
K{semiExitView === "short" ? "" : "+"}
{fmt(semiMove, 0)}&gt;0 /
{fmt(semiExitU, 1)}×k
</>
) : isOo ? (
+14 -2
View File
@@ -474,10 +474,22 @@ input {
}
.plan-semi-tab {
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 10px;
margin-bottom: 12px;
align-items: start;
}
.plan-semi-tab > .card {
margin-bottom: 0;
min-width: 0;
}
@media (max-width: 960px) {
.plan-semi-tab {
grid-template-columns: 1fr;
}
}
.plan-semi-compact {