Understand your study
What this lab does
It compares two portfolios made of SPY and cash. Choose each stock allocation, a time horizon, a market scenario, account treatment, fees, contribution schedule, and spending. The calculation runs locally in your browser; no account login or AI service is needed.
The SPY & Cash study asks about the cost of keeping cash. The Dollar-Cost Averaging starts with no invested balance, adds $500 at the end of each month for 10 years, and compares immediate investing with holding those contributions in cash until each year-end. Its 7% growth tendency and other settings are editable teaching assumptions. The Retirement Withdrawals study asks whether a fixed, inflation-adjusted spending plan is funded throughout 30 years. Change the spending amount, save each run, and compare the funding percentages. The lab does not select a universally safe withdrawal rate.
These are simulated paths under chosen assumptions. They are not historical SPY results, market forecasts, or a complete retirement plan. Bonds, other assets, options, pensions, Social Security, changing market regimes, and historical backtesting are outside this sub-lab's first version.
Dollar-cost averaging and what you compare
Choose an amount and an interval: for example, $500 every 1 month or $250 every 2 weeks. Dollar-cost averaging means investing a fixed dollar amount repeatedly; it buys more of an investment when its price is lower and less when its price is higher. The lab tracks investment values and purchase cost basis rather than displaying a share count.
- Same contributions, different portfolios: identical new money arrives in both accounts at the same times. Each payment follows that account’s selected stock/cash allocation.
- Invest gradually vs invest all upfront: both accounts already have the full starting funds. The portfolio starts in interest-earning cash and transfers the selected dollar amount into SPY on schedule, capped by cash available. The benchmark buys SPY at the start. No new money is added. Cash interest can leave a residual balance even after purchases total the original principal; the schedule continues purchasing while cash remains.
- Invest each contribution vs collect cash first: both accounts invest any initial balance in SPY and receive identical new payments. The portfolio immediately invests each payment in SPY. The benchmark earns cash interest while waiting, then invests all accumulated cash at the end of every chosen holding period—or only at the end of the whole study.
Use a starting balance of zero when beginning from new savings. Timing comparisons disable withdrawals and rebalancing so they isolate investment timing. If contributions and a cash purchase occur on the same date, the new contribution is included in that purchase. If the next purchase date falls beyond the study horizon, the remaining money stays in cash. A purchase at the very end of the study has no subsequent time to earn a stock return.
Beginning-of-interval payments start at time zero and stop before the horizon. End-of-interval payments first occur after a complete interval and include the horizon when a payment is due there. A one-year monthly schedule therefore has 12 payments in either case. The model uses 52 equal weeks and 12 equal months per year, not actual calendar dates or holiday-adjusted trading days. Weekly transactions are processed at their own times, not rounded into monthly deposits.
The table separates new contributions from gains. Net investment gain equals ending balance plus net spending received, minus starting capital and new contributions. It is after modeled taxes and fees and is a dollar amount, not a return percentage. Cash interest counts as an investment gain. In upfront mode, transfers from cash into SPY are not contributions.
Old saved settings with an annual deposit retain the old meaning: once a year at the beginning. New exports record comparison type, amount, interval, payment timing, and any cash holding period. Changing the event schedule changes the sequence of simulated paths; the two accounts within a run still share exactly the same stock movements. Old saved runs keep their original results and engine version.
Market controls
Growth tendency is the drift parameter of a geometric Brownian motion model: the expected total-return multiplier over one year is exp(growth/100). Thus a 15% drift means about 16.18% expected annual growth, not a promised 15% return. Volatility controls the size of random fluctuations. Returns compound; annual drift and volatility stay constant, and each interval’s random movement is independent.
Bull, neutral, and bear are teaching presets (+15%, 0%, −15% drift, each at 18% volatility). Custom lets you choose both numbers. A neutral drift has a below-start median when volatility is positive. Cash interest is an effective annual rate. Inflation is fixed and used to raise spending and deflate the chart.
For each interval of length Δt years, the stock total-return factor is exp((μ − σ²/2)Δt + σZ√Δt), with Z a standard normal draw. Both accounts receive the identical factor on each path. Distributions are included in total return. The dividend-yield setting separates out a tax estimate; it does not add another return.
Order of operations
- At each scheduled payment time, add new money in the chosen allocation, or transfer existing cash in the upfront comparison. The cash-accumulation benchmark buys SPY with all its cash at each selected holding-period end, after any contribution arriving at that same time.
- At the beginning of each year in portfolio mode, withdraw that year's requested net spending, increased with inflation if selected. Sell stock and cash proportionally. Gross up sales for modeled tax. Record any inability to fund the full payment; the path remains a failed funding path thereafter.
- Restore the target allocation if rebalancing is due. Realized positive stock gains can incur brokerage tax. A stock sale used to rebalance pays its own modeled tax.
- Apply the interval’s stock total return and cash interest, then modeled income taxes. Reinvest the after-tax dividend amount for cost-basis accounting.
- Deduct the annual fee continuously over the elapsed interval from both assets. Fees are charged to both portfolios; commissions and spreads are excluded.
- Record monthly balances before cash flows at that boundary. At the final observation include any final scheduled contribution and purchase. Repeat for all intervals and paths.
All holdings are fractional. Unfunded spending receives whatever is available after tax, and the account cannot borrow. A later deposit can refill an account but does not erase an earlier shortfall. Withdrawal success means every scheduled payment was fully funded; a final zero balance can still count as successful if every payment was met.
Taxes: explicit approximations
Taxes excluded: no account type is inferred. Traditional IRA: funds are assumed entirely pre-tax; no annual tax is charged inside the account and the chosen rate applies to gross withdrawals. Roth IRA: all withdrawals are assumed qualified, with no modeled tax.
Taxable brokerage: interest and modeled dividends are taxed at each calculation interval at your chosen fixed rates. Stock purchases start with basis equal to cost. Reinvested after-tax dividends add basis. Proportional stock sales remove proportional basis and charge the single gains rate only on positive realized gains. No tax credits or loss carryforwards are allowed. Rebalancing can therefore reduce an account through realized-gains tax.
This average-basis approximation does not implement actual SPY tax-lot reporting. It does not distinguish short- and long-term lots, dividend qualification, federal and state brackets, exemptions, loss offsets, RMDs, contribution eligibility, deduction benefits, early withdrawal penalties, or mixed pre-/after-tax IRA basis. Enter combined effective rates appropriate to the scenario you want to test. Deposits are scenario cash flows, not approved IRA contributions.
Final account values are before hypothetical liquidation or distribution tax; use spending received and taxes paid as well as balances when comparing account types.
For the underlying tax distinctions, see the IRS guidance on dividends, traditional and Roth IRAs, and investment income and expenses. The lab's simplified tax calculation is not a tax return calculator.
Read and keep the results
The fan chart shows the median and 5th–95th percentile balances at every month, including depleted accounts. Its purchasing-power button divides each point by accumulated inflation. The table always uses nominal dollars. “Ends below starting balance” must not be read as investment loss when cash flows are present.
Save settings to reuse inputs in this browser. Save a run to keep its recorded inputs, computed results, and assessment. Browser storage is limited and may be cleared; export JSON files for durable copies. Imported files load settings and require a fresh calculation rather than trusting unverified results. CSV exports contain both ending balances, funding flags, taxes, and spending for every paired path.
The method uses monthly observations with extra steps at payment dates, Mulberry32 uniform draws and Box–Muller normal draws, consumed in path-major order. Record the seed and engine version, INV-1.1.0. The same complete settings and engine reproduce a run. Changing the horizon changes how the random sequence is partitioned among paths.
Relationship to the book: these presets investigate the same questions, but the book's saved calculations use different time steps and a different random generator. This release does not reproduce Run 001 or RET-001 numerically. Treat site results as separate runs; use their own logbook and charts. Do not replace the book's recorded numbers without running and documenting a new study.