From 9f7b1b24e6296c8efe1008c8d0f2454e9b17b7ea Mon Sep 17 00:00:00 2001 From: dekun Date: Fri, 7 Aug 2026 17:32:49 +0800 Subject: [PATCH] =?UTF-8?q?Show=20=E6=B0=B8=E6=9C=9F/=E6=9C=9F=E6=9C=9F=20?= =?UTF-8?q?in=20control=20monitor=20mode=20column.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- backend/app/api/fleet.py | 15 +++++++++++++++ control/frontend/src/pages/Monitor.tsx | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/backend/app/api/fleet.py b/backend/app/api/fleet.py index 473deec..ee3148a 100644 --- a/backend/app/api/fleet.py +++ b/backend/app/api/fleet.py @@ -287,6 +287,21 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di "martingale_enabled": st.get("martingale_enabled"), "martingale_doubles": st.get("martingale_doubles"), "risk_effective_loss_pct": st.get("risk_effective_loss_pct"), + "hedge_mode": ( + hm + if ( + hm := str( + st.get("hedge_mode") + or db.get_setting("hedge_mode", settings.hedge_mode) + or settings.hedge_mode + or "perp_option" + ) + .strip() + .lower() + ) + in ("perp_option", "option_option") + else "perp_option" + ), }, "position": { "status": pos.get("status") or ("open" if pos.get("has_position") else "flat"), diff --git a/control/frontend/src/pages/Monitor.tsx b/control/frontend/src/pages/Monitor.tsx index 199b0e3..edfa877 100644 --- a/control/frontend/src/pages/Monitor.tsx +++ b/control/frontend/src/pages/Monitor.tsx @@ -235,18 +235,27 @@ function riskLines(strat: Record): RiskLines { }; } +function hedgeModeShort(strat: Record): string { + const hm = String(strat.hedge_mode || "perp_option") + .trim() + .toLowerCase(); + return hm === "option_option" ? "期期" : "永期"; +} + function modeLabel(mode: string, strat: Record): string { const m = String(mode || "-").toUpperCase(); const short = m.includes("LIVE") ? "LIVE" : m.includes("SIM") ? "SIM" : m || "-"; - // A=以损定仓,B=手动开仓 - return `${short}/${riskLines(strat).sizingShort}`; + // A=以损定仓,B=手动开仓;永期=永续+期权,期期=双期权 + return `${short}/${riskLines(strat).sizingShort}/${hedgeModeShort(strat)}`; } function modeLabelTitle(mode: string, strat: Record): string { const label = modeLabel(mode, strat); const riskBased = strat.sizing_mode === "risk_based" || strat.risk_based === true; - return `${label}(${riskBased ? "A=以损定仓" : "B=手动开仓"})`; + const hedge = + hedgeModeShort(strat) === "期期" ? "期期=双期权对冲" : "永期=永续+期权"; + return `${label}(${riskBased ? "A=以损定仓" : "B=手动开仓"};${hedge})`; } function tokenDotClass(n: { @@ -983,7 +992,8 @@ export default function MonitorPage() { {detailRunning ? "运行中" : "已停"} · {detail.phase} - {detail.mode} / {detail.exchange} + {modeLabel(detail.mode, detail.strat)} /{" "} + {detail.exchange} {detail.rounds ?? "—"}