feat(research): disclose saved result provenance and limitations

This commit is contained in:
Boki 2026-10-22 14:50:24 -04:00
parent 43ffb547be
commit fe00ecd0e2
12 changed files with 456 additions and 12 deletions

View file

@ -7,6 +7,7 @@ interface ExtendedMetrics {
maxDrawdown?: number | null;
winRate?: number | null;
totalProfit?: number | null;
totalPnl?: number | null;
profitFactor?: number | null;
totalTrades?: number | null;
avgWin?: number | null;
@ -55,10 +56,13 @@ export function CompactPerformanceMetrics({ result, isLoading }: CompactPerforma
...metrics,
};
// Calculate totalProfit if not provided
// Never infer a historical cash amount from a mutable legacy definition's capital.
const totalProfit =
allMetrics.totalProfit ??
(typeof allMetrics.totalReturn === 'number' && typeof result.config?.initialCapital === 'number'
allMetrics.totalPnl ??
(result.provenance?.configurationSource === 'stored-snapshot' &&
typeof allMetrics.totalReturn === 'number' &&
typeof result.config?.initialCapital === 'number'
? allMetrics.totalReturn * result.config.initialCapital
: undefined);