Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apursley2012/airgead-investment-calculator/llms.txt

Use this file to discover all available pages before exploring further.

Airgead uses a monthly compounding model to project investment growth. Rather than applying interest once per year, the engine divides the annual rate by 12 to derive a monthly rate, applies that rate to two running balances on every monthly cycle, and records a single snapshot row at the end of each year. This produces a year-by-year table that shows exactly how regular contributions amplify the effect of compounding over time.

The Monthly Rate Conversion

Before the main loop runs, the annual interest rate entered by the user is converted to a monthly equivalent:
monthly rate = annual rate / 100 / 12
Dividing by 100 converts the percentage to a decimal, and dividing by 12 spreads it evenly across the twelve monthly periods in a year. For example, a 6% annual rate becomes a monthly rate of 0.005 (0.5%).

Two Parallel Balances

Every calculation tracks two balances in lockstep, both initialised to startingBalance. A third accumulator, totalDeposits, tracks the total principal contributed so that interest earned can be isolated at the end. Each month, the inner loop performs these three operations in order:
  1. Both balances are multiplied by (1 + monthlyRate) — this is the compounding step
  2. monthlyDeposit is added only to withDeposits — the contributions scenario
  3. monthlyDeposit is added to totalDeposits — the principal tracker
Here is the exact inner loop extracted from js/lib/calculator.js:
for (let m = 0; m < 12; m++) {
  withDeposits = withDeposits * (1 + monthlyRate) + monthlyDeposit;
  withoutDeposits = withoutDeposits * (1 + monthlyRate);
  totalDeposits += monthlyDeposit;
}
After all 12 months have been processed, a result row is pushed into the output array for that year.
The results array always begins with a year-zero row that represents the initial state before any compounding or deposits have occurred. All four values at year 0 reflect the raw startingBalance exactly as entered, and interestEarned is always 0. This is why the results table runs from Year 0 through Year N rather than Year 1 through Year N.

The Result Row Shape

Each entry in the returned array has the following fields:
year
number
The year index. 0 represents the initial state before compounding begins; subsequent integers correspond to each completed year of the projection.
withDeposits
number
The projected balance at the end of the year, assuming the specified monthly deposit is made every month. Rounded to the nearest whole dollar.
withoutDeposits
number
The projected balance at the end of the year if no additional deposits are ever made — only the startingBalance compounds. Rounded to the nearest whole dollar.
totalDeposits
number
The cumulative principal contributed: the original startingBalance plus every monthly deposit made up to and including this year. Rounded to the nearest whole dollar. This value is used to calculate interestEarned.
interestEarned
number
The growth attributable purely to compound interest: withDeposits − totalDeposits. This isolates the interest component from contributions. Rounded to the nearest whole dollar. Always 0 on the year-zero row.

Input Clamping

Before any calculation runs, all four inputs are sanitised to prevent invalid or extreme values from producing nonsensical output:
  • startingBalance — clamped to Math.max(0, ...): cannot be negative
  • monthlyDeposit — clamped to Math.max(0, ...): cannot be negative
  • annualRate — clamped to Math.max(0, ...): cannot be negative
  • years — clamped to Math.min(80, Math.max(0, Math.round(...))): must be a non-negative whole number, capped at 80 years
Non-numeric inputs are coerced to 0 via Number(value) || 0 before clamping is applied.

What This Model Does Not Include

The calculation is intentionally simplified for educational purposes. It does not account for real-world factors that would affect an actual investment portfolio.
Airgead’s compound interest model does not account for any of the following:
  • Changing interest rates — the annual rate is held constant for the full projection period
  • Inflation — future values are expressed in nominal terms, not real (inflation-adjusted) terms
  • Account fees or management charges — no expense ratios or advisory fees are deducted
  • Taxes — no capital gains, dividend, or income tax is applied to growth
  • Contribution timing differences — deposits are assumed to occur at the same point within each month
  • Market volatility — returns are treated as perfectly smooth and consistent year over year
  • Withdrawal activity — no partial withdrawals or required minimum distributions are modelled
For real financial planning, consult a licensed financial adviser.

Build docs developers (and LLMs) love