feat: 迁移 Alpha 指标配色并以 bps 展示 Margin

This commit is contained in:
yuxuanhui
2026-09-10 15:31:09 +08:00
parent 1e67f43012
commit 1a7d92a708
+30 -2
View File
@@ -67,6 +67,31 @@ const metricLabels = {
prod_correlation: "平台生产相关性",
pnl: "IS PnL",
};
const metricColorThresholds: Record<string, [number, number, number]> = {
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) => (
<span className="numeric">
{formatNumber(row![key as keyof Alpha], key === "margin" ? 6 : 3)}
<span
className="numeric"
style={{ color: metricColor(key, row![key as keyof Alpha]) }}
>
{formatMetric(key, row![key as keyof Alpha])}
</span>
),
}),