fix: allow repeated platform checks and unify Alpha metric formatting
Deploy production / deploy (push) Successful in 54s

This commit is contained in:
yuxuanhui
2026-09-12 22:42:37 +08:00
parent c18960946b
commit f3eb239e1a
8 changed files with 196 additions and 17 deletions
+12
View File
@@ -0,0 +1,12 @@
/** Format the five headline Alpha metrics for display; stored/filter values stay raw.
* Unsupported fields return undefined so callers can retain their existing format.
*/
export function formatAlphaMetric(
key: string,
value: unknown,
): string | undefined {
const percent = key === "turnover" || key === "returns" || key === "drawdown";
if (!percent && key !== "sharpe" && key !== "fitness") return undefined;
if (typeof value !== "number" || !Number.isFinite(value)) return "—";
return percent ? `${(value * 100).toFixed(2)}%` : value.toFixed(2);
}