Add 永期半自动: human arm, machine open/close, then stop.

Settings toggle, Plan panel, Fleet monitor, exit locks and armed TOCTOU gates; docs and dual audits.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-08 11:20:11 +08:00
parent bf3441537e
commit 4585dba3c3
22 changed files with 1147 additions and 44 deletions
+45 -5
View File
@@ -162,6 +162,8 @@ const CLOSE_REASON_ZH: Record<string, string> = {
fixed_usdt: "固定净盈利达标·双腿全平",
premium_multiple: "权利金倍数达标·双腿全平",
target_perp_only: "净盈利达标·只平永续(期权归档)",
semi_target_points: "半自动·标的到点且组合净利>0",
semi_perp_exit: "半自动·净利基数达标",
expiry: "到期结算",
emergency: "紧急全平",
manual: "手动平仓",
@@ -321,7 +323,9 @@ function hedgeModeShort(strat: Record<string, unknown>): string {
const hm = String(strat.hedge_mode || "perp_option")
.trim()
.toLowerCase();
return hm === "option_option" ? "期期" : "永期";
if (hm === "option_option") return "期期";
if (strat.semi_auto_enabled === true) return "半自动";
return "永期";
}
function modeParts(
@@ -354,7 +358,15 @@ function ModeLabelView({
return (
<>
{p.head}/
<span className={p.isOo ? "mode-hedge-oo" : "mode-hedge-po"}>
<span
className={
p.isOo
? "mode-hedge-oo"
: p.hedge === "半自动"
? "mode-hedge-semi"
: "mode-hedge-po"
}
>
{p.hedge}
</span>
</>
@@ -366,7 +378,11 @@ function modeLabelTitle(mode: string, strat: Record<string, unknown>): string {
const riskBased =
strat.sizing_mode === "risk_based" || strat.risk_based === true;
const hedge =
hedgeModeShort(strat) === "期期" ? "期期=双期权对冲" : "永期=永续+期权";
hedgeModeShort(strat) === "期期"
? "期期=双期权对冲"
: hedgeModeShort(strat) === "半自动"
? "半自动=人工看法·机器盯盘开平·平仓后停"
: "永期=永续+期权";
return `${label}${riskBased ? "A=以损定仓" : "B=手动开仓"}${hedge}`;
}
@@ -1126,7 +1142,23 @@ export default function MonitorPage() {
{r.openRatio ? <td>{r.openRatio}</td> : null}
<td title={r.leverageTitle}>{r.leverage}</td>
<td>
{detailRunning ? "运行中" : "已停"} · {detail.phase}
{detailRunning ? "运行中" : "已停"} ·{" "}
{detail.phase === "wait_human"
? "等待人工授权"
: detail.phase}
{detail.strat.semi_auto_enabled === true ? (
<span className="meta">
{" "}
·
{detail.strat.semi_armed === true
? "已授权"
: "未授权"}
·
{detail.strat.semi_view_side === "short"
? "空"
: "多"}
</span>
) : null}
</td>
<td>
<ModeLabelView
@@ -1160,7 +1192,15 @@ export default function MonitorPage() {
4,
)} ETH`}
</td>
<td>{fmt(detail.strat.exit_target_usdt, 2)} USDT</td>
<td>
{detail.strat.semi_auto_enabled === true
? `半自动·点${fmt(detail.strat.semi_option_move_points, 0)}/净≥${fmt(
detail.strat.semi_net_exit_target ??
detail.strat.semi_perp_exit_unit,
2,
)}U`
: `${fmt(detail.strat.exit_target_usdt, 2)} USDT`}
</td>
<td className="mono">
{fmtExPx("perp", detail.index_px)}
</td>
+5
View File
@@ -424,6 +424,11 @@ input {
color: var(--muted);
}
.mode-hedge-semi {
color: #5ec8ff;
font-weight: 700;
}
.dot {
width: 9px;
height: 9px;