import type { BacktestResult } from '../types/backtest.types'; import { MetricsCard } from './MetricsCard'; interface BacktestMetricsProps { result: BacktestResult | null; isLoading: boolean; } const ratioLabel = (value: number | null | undefined) => typeof value === 'number' && Number.isFinite(value) ? value.toFixed(2) : 'N/A'; // Full detailed metrics view - can be used as a separate page/view if needed export function BacktestMetrics({ result, isLoading }: BacktestMetricsProps) { if (isLoading) { return (
{[...Array(6)].map((_, i) => (
))}
); } if (!result) { return (

Run a backtest to see performance metrics.

); } const { metrics } = result; return (
= 0 ? 'up' : 'down'} /> 0 ? 'up' : 'down' } /> 0.5 ? 'up' : 'down'} /> 1 ? 'up' : 'down' } />

Trade Statistics

Profitable Trades {metrics.profitableTrades ?? 0}
Average Win ${(metrics.avgWin ?? 0).toFixed(2)}
Average Loss ${Math.abs(metrics.avgLoss ?? 0).toFixed(2)}
Expectancy = 0 ? 'text-success' : 'text-error'}`} > ${(metrics.expectancy ?? 0).toFixed(2)}

Risk Metrics

Calmar Ratio {ratioLabel(metrics.calmarRatio)}
Sortino Ratio {ratioLabel(metrics.sortinoRatio)}
Exposure Time {typeof result.analytics?.exposureTime === 'number' ? `${(result.analytics.exposureTime * 100).toFixed(1)}%` : 'N/A'}
); }