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.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.
The Monthly Rate Conversion
Before the main loop runs, the annual interest rate entered by the user is converted to a monthly equivalent:0.005 (0.5%).
Two Parallel Balances
Every calculation tracks two balances in lockstep, both initialised tostartingBalance. 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:
- Both balances are multiplied by
(1 + monthlyRate)— this is the compounding step monthlyDepositis added only towithDeposits— the contributions scenariomonthlyDepositis added tototalDeposits— the principal tracker
js/lib/calculator.js:
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:The year index.
0 represents the initial state before compounding begins; subsequent integers correspond to each completed year of the projection.The projected balance at the end of the year, assuming the specified monthly deposit is made every month. Rounded to the nearest whole dollar.
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.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.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 toMath.max(0, ...): cannot be negativemonthlyDeposit— clamped toMath.max(0, ...): cannot be negativeannualRate— clamped toMath.max(0, ...): cannot be negativeyears— clamped toMath.min(80, Math.max(0, Math.round(...))): must be a non-negative whole number, capped at 80 years
0 via Number(value) || 0 before clamping is applied.