From 1a7d92a708275f44d9366f11eb9c05760c8479d7 Mon Sep 17 00:00:00 2001 From: yuxuanhui Date: Thu, 10 Sep 2026 15:31:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=81=E7=A7=BB=20Alpha=20=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E9=85=8D=E8=89=B2=E5=B9=B6=E4=BB=A5=20bps=20=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=20Margin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/AlphaPage.tsx | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/AlphaPage.tsx b/frontend/src/pages/AlphaPage.tsx index 92206ef..f4ed3bb 100644 --- a/frontend/src/pages/AlphaPage.tsx +++ b/frontend/src/pages/AlphaPage.tsx @@ -67,6 +67,31 @@ const metricLabels = { prod_correlation: "平台生产相关性", pnl: "IS PnL", }; +const metricColorThresholds: Record = { + sharpe: [1.5, 1.0, 0.5], + fitness: [0.75, 0.5, 0.25], + returns: [0.15, 0.1, 0.05], +}; + +/** Preserve the legacy list's strict thresholds; missing values have no rating. */ +function metricColor(key: string, value: unknown): string | undefined { + const thresholds = metricColorThresholds[key]; + if (!thresholds || typeof value !== "number" || !Number.isFinite(value)) + return undefined; + if (value > thresholds[0]) return "var(--semi-color-success)"; + if (value > thresholds[1]) return "var(--semi-color-info)"; + if (value > thresholds[2]) return "var(--semi-color-warning)"; + return "var(--semi-color-danger)"; +} + +/** Convert Margin only for display; filtering and sorting still use raw values. */ +function formatMetric(key: string, value: unknown): string { + if (key !== "margin") return formatNumber(value, 3); + return typeof value === "number" && Number.isFinite(value) + ? `${formatNumber(value * 10000, 2)}bps` + : "—"; +} + const checkLabels = { PENDING: "待检查", PRE_CHECK: "预检通过", @@ -478,8 +503,11 @@ export function AlphaPage({ : 112, align: "right", render: (_, row) => ( - - {formatNumber(row![key as keyof Alpha], key === "margin" ? 6 : 3)} + + {formatMetric(key, row![key as keyof Alpha])} ), }),