Money forecast: name the first crash after the calm start in the explanation
All checks were successful
Deploy production / deploy (push) Successful in 1m14s
All checks were successful
Deploy production / deploy (push) Successful in 1m14s
This commit is contained in:
@@ -105,6 +105,13 @@
|
||||
let result = $derived(results[selected]);
|
||||
let markets = $derived(marketReturns(active, result.years[0]?.year));
|
||||
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. */
|
||||
let shocks = $derived(
|
||||
Array.from({ length: 11 }, (_, offset) => (result.years[0]?.year ?? 0) + offset)
|
||||
@@ -176,7 +183,7 @@
|
||||
earn the {active.returnPercent}% average.
|
||||
{/if}
|
||||
{#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`
|
||||
: ''}, and {percent(normalReturn)} in the other years so it averages out{markets.calmUntil !==
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user