Filter semi ladder to 2 OTM/ITM or 1 ATM by moneyness selection.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-08 14:18:03 +08:00
parent 58c12aa160
commit ebd88718a7
+61 -14
View File
@@ -915,29 +915,75 @@ export default function PlanPage() {
</tr>
</thead>
<tbody>
{(ladder.rows || []).map((r) => {
{(() => {
const all = ladder.rows || [];
let shown = all;
if (semiMny === "atm") {
shown = all.filter((r) => r.tag === "atm").slice(0, 1);
} else if (semiMny === "otm") {
shown = all
.filter(
(r) =>
r.tag === "otm" &&
Math.abs(r.offset) <=
Number(semiOtmOff) + 1e-9,
)
.sort(
(a, b) =>
Math.abs(a.offset) - Math.abs(b.offset),
)
.slice(0, 2);
// Call:虚值高行权在上;Put:虚值低行权在上
shown.sort((a, b) =>
semiView === "short"
? a.strike - b.strike
: b.strike - a.strike,
);
} else {
// 实值:最接近现价的 2 档
shown = all
.filter((r) => r.tag === "itm")
.sort(
(a, b) =>
Math.abs(a.offset) - Math.abs(b.offset),
)
.slice(0, 2);
shown.sort((a, b) =>
semiView === "short"
? a.strike - b.strike
: b.strike - a.strike,
);
}
if (shown.length === 0) {
return (
<tr>
<td colSpan={4} className="meta">
{semiMny === "itm"
? "实值"
: semiMny === "atm"
? "平值"
: "虚值"}
{semiMny === "otm"
? `(偏离≤${fmt(semiOtmOff, 0)}`
: ""}
</td>
</tr>
);
}
return shown.map((r) => {
const tagZh =
r.tag === "atm"
? "平值"
: r.tag === "itm"
? "实值"
: "虚值";
const hi =
(semiMny === "otm" &&
r.tag === "otm" &&
Math.abs(r.offset) <= Number(semiOtmOff) + 1e-9) ||
(semiMny === "atm" && r.tag === "atm") ||
(semiMny === "itm" &&
(r.tag === "itm" || r.tag === "atm"));
return (
<tr
key={r.strike}
className={
r.tag === "atm"
? "plan-t-atm"
: hi
? "plan-t-pick"
: undefined
r.tag === "atm" ? "plan-t-atm" : "plan-t-pick"
}
>
<td className="mono plan-t-k">
@@ -957,7 +1003,8 @@ export default function PlanPage() {
</td>
</tr>
);
})}
});
})()}
</tbody>
</table>
</div>