fix: allow repeated platform checks and unify Alpha metric formatting
Deploy production / deploy (push) Successful in 54s
Deploy production / deploy (push) Successful in 54s
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user