Money forecast: name the first crash after the calm start in the explanation
All checks were successful
Deploy production / deploy (push) Successful in 1m14s

This commit is contained in:
2026-10-26 08:29:28 +00:00
parent 78b69c7d8f
commit 21b10ea894

View File

@@ -105,6 +105,13 @@
let result = $derived(results[selected]); let result = $derived(results[selected]);
let markets = $derived(marketReturns(active, result.years[0]?.year)); let markets = $derived(marketReturns(active, result.years[0]?.year));
let normalReturn = $derived(markets.normal); let normalReturn = $derived(markets.normal);
/** First crash after any calm start. */
let firstCrash = $derived.by(() => {
let year = active.firstCrashYear;
const every = Math.max(1, Math.round(active.crashEveryYears));
while (markets.calmUntil !== null && year <= markets.calmUntil) year += every;
return year;
});
/** Crash and correction years in the first ten years, for the explanation. */ /** Crash and correction years in the first ten years, for the explanation. */
let shocks = $derived( let shocks = $derived(
Array.from({ length: 11 }, (_, offset) => (result.years[0]?.year ?? 0) + offset) Array.from({ length: 11 }, (_, offset) => (result.years[0]?.year ?? 0) + offset)
@@ -176,7 +183,7 @@
earn the {active.returnPercent}% average. earn the {active.returnPercent}% average.
{/if} {/if}
{#if active.crashPercent !== 0}A {active.crashPercent}% crash every {active.crashEveryYears} years {#if active.crashPercent !== 0}A {active.crashPercent}% crash every {active.crashEveryYears} years
from {active.firstCrashYear}{active.correctionPercent !== 0 from {firstCrash}{active.correctionPercent !== 0
? `, a ${active.correctionPercent}% correction halfway between` ? `, a ${active.correctionPercent}% correction halfway between`
: ''}, and {percent(normalReturn)} in the other years so it averages out{markets.calmUntil !== : ''}, and {percent(normalReturn)} in the other years so it averages out{markets.calmUntil !==
null null