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])} ), }),