A simple tool to see whether steady monthly investing could get you to retirement, tested against 98 years of S&P 500 history.
Published
Nov 28, 2026
Working in private banking and having started to read more about personal finance, I keep coming back to one question: am I saving enough for retirement?
I built this tool to picture how investing a little every month, slowly and consistently, could get me there. Plug in your own numbers and see how the plan holds up in a bear market, a typical one, and a bull run, each drawn from real S&P 500 returns from 1928 through 2025.
This isn’t the final word on investing, just a starting point. Before acting on any plan, think about your ability and willingness to take risk, taxes, fees, and anything else in your own situation that a simple calculator can’t see.
This is not financial advice. It’s for educational purposes only.
Three ways the market could go
Bear market Usually means prices falling 20% or more from a recent high. Here, it’s a long stretch of weak returns: only 1 in 5 historical stretches did worse.
Base case The middle of the road. It’s the typical outcome: half of all historical stretches did better and half did worse.
Bull market Usually means prices rising 20% or more from a recent low. Here, it’s a long stretch of strong returns: only 1 in 5 historical stretches did better.
All returns here are real returns: what the S&P 500 earned after inflation. Since 1928 that has averaged about 7% a year, versus about 10% before inflation. Planning in real terms keeps every number in today’s money, so $1 million at the end means what $1 million buys today.
Your plan
All amounts are in US dollars (USD). The returns come from the S&P 500, which is priced in dollars. If you save in pesos, convert your numbers to dollars first.
Show code
viewof initial =amountInput({label:"Starting amount",value:10000})viewof contribution =amountInput({label:"Regular contribution",value:500})viewof frequency = Inputs.select(newMap([["Every month",12], ["Every quarter",4], ["Every year",1]]), {label:"How often",value:12})viewof years = Inputs.range([1,50], {label:"Years until retirement",value:25,step:1})viewof goal =amountInput({label:"Yearly income you want in retirement",value:40000})viewof withdrawal = Inputs.range([2,8], {label:"Withdrawal rate (%)",value:4,step:0.1})viewof inflation = Inputs.range([0,10], {label:"Inflation (%)",value:3,step:0.1})viewof growContrib = Inputs.toggle({label:"Raise contributions with inflation",value:true})
Show code
verdict = {const base = results.find(r => r.name==="Base");const ok = base.income>= goal;returnhtml`<div class="verdict ${ok ?"verdict-ok":"verdict-short"}"> <div class="verdict-kicker">In a typical market</div> <div class="verdict-headline">You'd retire with <strong>${money(base.real)}</strong> in today's money, enough for <strong>${money(base.income)}</strong> a year.</div> <div class="verdict-status"> <span class="verdict-icon">${ok ?"✓":"✕"}</span>${ok?html`That covers your ${money(goal)} goal, with ${money(base.income- goal)} a year to spare.`:html`That's ${money(goal - base.income)} a year short of your ${money(goal)} goal. You'd need about ${money(target)} saved.`} </div> </div>`;}
Show code
html`<div class="scenario-cards">${results.map(r => {const pct =Math.min(r.income/ goal,1.5);const ok = r.income>= goal;returnhtml`<div class="scenario-card" style="--accent:${r.color}"> <div class="scenario-name"><span class="dot"></span>${r.name}<span class="scenario-rate">${(r.rate*100).toFixed(1)}% a year<br><span class="scenario-hist">after inflation</span></span></div> <div class="scenario-balance">${money(r.real)}</div> <div class="scenario-sub">${money(r.income)} a year · ${money(r.income/12)} a month</div> <div class="goal-bar"><div class="goal-fill" style="width:${Math.min(pct,1) *100}%"></div></div> <div class="scenario-goal">${ok ?"✓":"✕"}${Math.round(r.income/ goal *100)}% of your goal</div> </div>`;})}</div>`
How your money grows
Show code
{const key = realView ?"real":"nominal";const cKey = realView ?"contribReal":"contributed";const base = paths.filter(d => d.scenario==="Base");const band = base.map((d, i) => ({year: d.year,lo: bearPath[i][key],hi: bullPath[i][key]}));const last = paths.filter(d => d.year=== years);// keep end-of-line labels from overlappingconst top =Math.max(realView ? target :0,...last.map(d => d[key]));const gap = top *0.06;let prev =-Infinity;const labels = [...last].sort((a, b) => a[key] - b[key]).map(d => {const y =Math.max(d[key], prev + gap); prev = y;return {...d,labelY: y}; });return Plot.plot({ width,height:420,marginLeft:64,marginRight:140,style: {fontSize:"13px",fontFamily:"Inter, system-ui, sans-serif"},x: {label:"Years from now",tickFormat:"d",ticks:Math.min(years, width <500?5:10)},y: {label:null,grid:true,tickFormat: d =>shortMoney(d)},marks: [ Plot.areaY(base, {x:"year",y: cKey,fill: ink.muted,fillOpacity:0.12,curve:"monotone-x"}), Plot.areaY(band, {x:"year",y1:"lo",y2:"hi",fill: colors[1],fillOpacity:0.10,curve:"monotone-x"}), realView ? Plot.ruleY([target], {stroke: ink.text,strokeDasharray:"5,4",strokeOpacity:0.6}) :null, realView ? Plot.text([target], {x: years,y: d => d,text: d =>`What you need: ${shortMoney(d)}`,textAnchor:"end",dy:-8,fill: ink.text,fontWeight:600}) :null, Plot.line(paths, {x:"year",y: key,z:"scenario",stroke: d => colorOf[d.scenario],strokeWidth: d => d.scenario==="Base"?3:2,curve:"monotone-x"}), Plot.dot(last, {x:"year",y: key,fill: d => colorOf[d.scenario],r:5,stroke: ink.bg,strokeWidth:2}), Plot.text(labels, {x:"year",y:"labelY",text: d =>`${d.scenario}${shortMoney(d[key])}`,textAnchor:"start",dx:10,fill: ink.text,fontWeight:600}), Plot.text([{year: years,v: base.at(-1)[cKey]}], {x:"year",y:"v",text: () =>"You put in",textAnchor:"start",dx:10,fill: ink.muted}), Plot.ruleX(paths, Plot.pointerX({x:"year",stroke: ink.muted,strokeOpacity:0.5})), Plot.dot(paths, Plot.pointerX({x:"year",y: key,fill: d => colorOf[d.scenario],r:4})), Plot.tip(base, Plot.pointerX({x:"year",y: key,title: d => {const rows = scenarioNames.map(n =>`${n}: ${money(paths.find(p => p.scenario=== n && p.year=== d.year)[key])}`);return [`Year ${d.year}`,...rows,`You put in: ${money(d[cKey])}`].join("\n"); }})) ] });}
Show code
viewof realView = Inputs.toggle({label:"Show in today's money (adjusted for inflation)",value:true})
Where the scenarios come from
Show code
{const bins = d3.bin().thresholds(28).value(d => d.cagr)(windows);const zone = x => x < byName.Bear.hist?0: x <= byName.Bull.hist?1:2;const bars = bins.map(b => ({x1: b.x0,x2: b.x1,n: b.length,z:zone((b.x0+ b.x1) /2),starts: b.map(d =>`${d.start}–${d.start+ years -1}`)}));const listYears = a => a.length<=6? a.join("\n") : [...a.slice(0,6),`+ ${a.length-6} more`].join("\n");return Plot.plot({ width,height:260,marginTop:44,marginLeft:40,marginBottom:48,style: {fontSize:"12px",fontFamily:"Inter, system-ui, sans-serif"},x: {label: width <500?`Yearly return, ${years}-year stretches`:`Average yearly return after inflation, every ${years}-year stretch since 1928`,labelAnchor:"center",labelOffset:42,labelArrow:"none",tickFormat: d =>`${Math.round(d *100)}%`},y: {label:"Stretches",grid:true},marks: [ Plot.rectY(bars, {x1:"x1",x2:"x2",y:"n",fill: d => colors[d.z],fillOpacity:0.35,insetLeft:1,insetRight:1,rx:3,tip:true,title: d =>`${(d.x1*100).toFixed(1)}–${(d.x2*100).toFixed(1)}% a year · ${d.n} stretch${d.n===1?"":"es"}\n${listYears(d.starts)}`}), Plot.ruleY([0], {stroke: ink.muted}), Plot.ruleX(scenarios, {x:"hist",stroke: d => d.color,strokeWidth:2.5}), Plot.text(scenarios.filter(d => d.name!=="Base"), {x:"hist",text: d =>`${d.name}${(d.hist*100).toFixed(1)}%`,frameAnchor:"top",dy:-12,fill: ink.text,fontWeight:600}), Plot.text(scenarios.filter(d => d.name==="Base"), {x:"hist",text: d =>`${d.name}${(d.hist*100).toFixed(1)}%`,frameAnchor:"top",dy:-28,fill: ink.text,fontWeight:600}) ] });}
Show code
html`<p class="chart-note"><strong>How to read this:</strong> each bar counts how many of the ${windows.length} stretches of ${years} years since 1928 earned that average yearly return after inflation. Hover a bar to see which years. <strong>Bear</strong> is the 20th percentile (1 in 5 did worse), <strong>Base</strong> the median, and <strong>Bull</strong> the 80th percentile (1 in 5 did better). The wider the bars spread, the more your start date matters. Try a shorter horizon to see it widen, or a longer one to see it narrow.</p>`
Yearly income is your withdrawal rate applied to your ending balance, in today’s money. Future dollars is the same amount in the dollars of your retirement year, using your inflation setting. Money lasts assumes you take that income every year (kept at today’s buying power) while the rest stays invested at the same scenario’s return.
Caveats and limitations
The past isn’t a forecast. This uses 98 years of US stocks, one of the world’s best markets. The future could be better or worse.
Real markets are bumpy. The scenarios assume a steady return. A crash near retirement hurts far more than one decades earlier.
It’s all stocks. Most portfolios also hold bonds or cash, which smooths the ride.
It’s in US dollars. The returns are for the S&P 500, measured in dollars. If you invest from the Philippines, moves in the peso–dollar exchange rate (FX) can add to or take away from your returns, so factor that in.
No taxes, fees or currency. All three can cut what you keep, especially if you invest in dollars but spend in pesos.
Retirement is simplified. It leaves out pensions, SSS, healthcare costs and changing spending.
It assumes you stay the course. Pausing contributions or panic-selling often costs more than any fee.
Everyone’s journey is different
Personal finance is, well, personal. What’s “enough” for you depends on your age, income, family, health, goals and comfort with risk. Start with an honest check:
Use this tool as a compass, not a map. Revisit your plan every year or whenever your life changes, and for decisions that matter, talk to a licensed financial professional.
Built with Claude, as a way to get back into coding and test what AI can do. The idea and the numbers are mine; Claude helped with the code and design.
Method and data
Returns are S&P 500 total returns (price plus reinvested dividends) for each calendar year, 1928–2025, adjusted for that year’s actual US inflation (CPI-U, December to December, from the St. Louis Fed’s FRED database).
2001–2025: the actual returns of BlackRock’s iShares Core S&P 500 ETF (IVV), from Yahoo Finance’s dividend-adjusted prices. These are what an investor in the fund really earned, after its small fee.
1928–2000: IVV didn’t exist yet (it launched in May 2000), so these years use the S&P 500 index itself, computed from Robert Shiller’s monthly dataset. Shiller uses monthly average prices, so individual years differ slightly from the official year-end figures.
Scenario returns are the real compound annual growth rate (CAGR) of every rolling stretch of your chosen length. Bear is the 20th percentile, base the median and bull the 80th percentile.
Your inflation setting doesn’t change the returns. It’s only used to show amounts in future dollars and, if you tick the box, to raise your contributions each year.
Keep in mind: rolling stretches overlap heavily, and US stocks had one of the best centuries of any market, so history may still flatter what’s ahead.
Each scenario uses one steady return every year. Real markets jump around, and the order of good and bad years matters a lot, especially once you start withdrawing.
What you need is your yearly income goal divided by your withdrawal rate.
Contributions are added at the end of each period. Fees and taxes are not included.
This is an educational tool, not financial advice.
Show code
data =FileAttachment("sp500_annual.csv").csv({typed:true})currency ="$"// Money input: shows commas as you type, plus a plain-words hint ("1.2 million")functionamountInput({label, value =0}) {const input =html`<input type="text" inputmode="numeric" autocomplete="off" spellcheck="false">`;const hint =html`<span class="amount-hint"></span>`;const form =html`<form class="oi-amount amount-input"><label>${label}</label><div class="amount-row"><span class="amount-field"><span class="amount-prefix">US$</span>${input}</span>${hint}</div></form>`;const withCommas = d3.format(",");const words = v => v >=1e9?`${+(v /1e9).toFixed(2)} billion`: v >=1e6?`${+(v /1e6).toFixed(2)} million`: v >=1e3?`${+(v /1e3).toFixed(1)} thousand`:"";const show = v => { form.value= v; hint.textContent=words(v); }; input.addEventListener("input", () => {const caret = input.selectionStart?? input.value.length;const digitsBefore = input.value.slice(0, caret).replace(/\D/g,"").length;const digits = input.value.replace(/\D/g,"").replace(/^0+(?=\d)/,"").slice(0,13);const v = digits ?+digits :0; input.value= digits ?withCommas(v) :"";// keep the cursor next to the same digit after commas are added or removedlet pos =0, seen =0;while (pos < input.value.length&& seen < digitsBefore) { if (/\d/.test(input.value[pos])) seen++; pos++; } input.setSelectionRange(pos, pos);show(v); }); form.addEventListener("submit", e => e.preventDefault()); input.value=withCommas(value);show(value);return form;}// Follow the site's light/dark toggle so chart colors match the themedark = Generators.observe(notify => {const check = () =>notify(document.body.classList.contains("quarto-dark"));check();const obs =newMutationObserver(check); obs.observe(document.body, {attributes:true,attributeFilter: ["class"]});return () => obs.disconnect();})colors = dark ? ["#d77a64","#6f95e0","#b88f2c"] : ["#b5513f","#2f5aa8","#9a7420"]ink = dark ? {text:"#e8e5de",muted:"#a09b91",bg:"#18191b"} : {text:"#2a2a2a",muted:"#6b665d",bg:"#fdfcf9"}scenarioNames = ["Bear","Base","Bull"]colorOf = ({"Bear": colors[0],"Base": colors[1],"Bull": colors[2]})windows = {const out = [];for (let i =0; i + years <= data.length; i++) {let g =1;for (let j = i; j < i + years; j++) g *=1+ data[j].real_return; out.push({start: data[i].year,cagr:Math.pow(g,1/ years) -1}); }return out;}scenarios = {const r = windows.map(d => d.cagr);return [0.2,0.5,0.8].map((q, k) => {const rate = d3.quantile(r, q);return {name: scenarioNames[k],color: colors[k],hist: rate, rate}; });}// rate is a REAL (after-inflation) return, so balances are in today's moneyfunctionsimulate(rate) {const f = frequency, i = inflation /100;const pr =Math.pow(1+ rate,1/ f) -1;let real = initial, putReal = initial, putNom = initial;const rows = [{year:0, real,contribReal: putReal,contributed: putNom}];for (let y =1; y <= years; y++) {const cNom = growContrib ? contribution *Math.pow(1+ i, y -1) : contribution;for (let p =0; p < f; p++) {const cReal = cNom /Math.pow(1+ i, y -1+ (p +1) / f); real = real * (1+ pr) + cReal; putReal += cReal; putNom += cNom; } rows.push({year: y, real,contribReal: putReal,contributed: putNom}); }return rows.map(d => ({...d,nominal: d.real*Math.pow(1+ i, d.year)}));}// years a real balance lasts when withdrawing a fixed real amount each yearfunctionlasts(start, rate) {let bal = start;const w = start * withdrawal /100;for (let y =1; y <=60; y++) { bal -= w;if (bal <=0) return y -1; bal *=1+ rate; }returnInfinity;}byName =Object.fromEntries(scenarios.map(s => [s.name, s]))bearPath =simulate(byName.Bear.rate)bullPath =simulate(byName.Bull.rate)paths = scenarios.flatMap(s =>simulate(s.rate).map(d => ({...d,scenario: s.name})))results = scenarios.map(s => {const end =simulate(s.rate).at(-1);return {...s,...end,income: end.real* withdrawal /100,lasts:lasts(end.real, s.rate)};})target = goal / (withdrawal /100)money = v => currency + d3.format(",.0f")(Math.round(v))shortMoney = v => currency + d3.format(".3~s")(v).replace("G","B")