fix(research): explain evaluation horizon and CAGR (RP04)
This commit is contained in:
parent
76eb1b1255
commit
302ba60e53
4 changed files with 117 additions and 2 deletions
|
|
@ -10,6 +10,24 @@ export function canonicalTime(timestamp: number): string {
|
|||
const date = new Date(timestamp);
|
||||
return Number.isFinite(date.getTime()) ? date.toISOString() : `${timestamp} ms since Unix epoch`;
|
||||
}
|
||||
function calendarDuration(milliseconds: string): string {
|
||||
let remaining = BigInt(milliseconds);
|
||||
const parts: string[] = [];
|
||||
for (const [size, unit] of [
|
||||
[86_400_000n, 'day'],
|
||||
[3_600_000n, 'hour'],
|
||||
[60_000n, 'minute'],
|
||||
[1000n, 'second'],
|
||||
[1n, 'millisecond'],
|
||||
] as const) {
|
||||
const count = remaining / size;
|
||||
remaining %= size;
|
||||
if (count > 0n) {
|
||||
parts.push(`${count} ${unit}${count === 1n ? '' : 's'}`);
|
||||
}
|
||||
}
|
||||
return parts.join(', ') || '0 seconds';
|
||||
}
|
||||
const reasonText = (reason: string | undefined) => reason?.replace(/-/g, ' ') ?? 'not reported';
|
||||
const metricFields: { key: keyof CanonicalMetrics; label: string; percentage?: boolean }[] = [
|
||||
{ key: 'totalReturn', label: 'Total return', percentage: true },
|
||||
|
|
@ -200,6 +218,20 @@ export function CanonicalResults({
|
|||
</section>
|
||||
<section className="space-y-3">
|
||||
<h3 className="font-semibold">Canonical metrics</h3>
|
||||
<dl aria-label="Evaluation horizon" className="grid gap-3 sm:grid-cols-3 text-sm">
|
||||
<div>
|
||||
<dt>Evaluation start (UTC)</dt>
|
||||
<dd>{canonicalTime(financial.reporting.tradeStart)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Evaluation end (UTC, exclusive)</dt>
|
||||
<dd>{canonicalTime(financial.reporting.tradeEnd)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Elapsed calendar duration</dt>
|
||||
<dd>{calendarDuration(financial.reporting.elapsedMs)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p className="text-sm text-text-secondary">
|
||||
{analytics.fillCount} fills · {analytics.completePeriodCount} complete periods ·{' '}
|
||||
{analytics.periodicSampleCount} statistical samples. Returns use fractions, displayed as
|
||||
|
|
@ -219,14 +251,20 @@ export function CanonicalResults({
|
|||
? `${(value * 100).toFixed(2)}%`
|
||||
: value.toFixed(2)}
|
||||
</dd>
|
||||
{field.key === 'cagr' && (
|
||||
<dd className="text-xs text-text-secondary">
|
||||
CAGR extrapolates this evaluation interval to a 365-calendar-day year, including
|
||||
nontrading time. It is not an observed annual return or a forecast.
|
||||
</dd>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</dl>
|
||||
<p className="text-xs text-text-secondary">
|
||||
Period calendar: {analytics.policy.calendarId}, revision{' '}
|
||||
{analytics.policy.calendarRevision}. Annualization: {analytics.policy.periodsPerYear}{' '}
|
||||
periods/year. Risk-free rate:{' '}
|
||||
{analytics.policy.calendarRevision}. Annualization for periodic statistics:{' '}
|
||||
{analytics.policy.periodsPerYear} periods/year. Risk-free rate:{' '}
|
||||
{analytics.policy.annualRiskFreeRate === null
|
||||
? 'unknown'
|
||||
: `${(analytics.policy.annualRiskFreeRate * 100).toFixed(2)}%`}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue