{
  "schemaVersion": 1,
  "slug": "sp-500-investment-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "7b4a8c4cf358c7f38d99eb9ffeec712057ecf8f75526e6aac08f44e77db5b4d7",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/sp-500-investment-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "FV = P₀(1+r)^n + M × ((1+r)^n − 1) ÷ r; r = R÷100÷12, n = 12Y",
    "vars": [
      [
        "P₀",
        "Initial amount"
      ],
      [
        "M",
        "Monthly contribution"
      ],
      [
        "R",
        "Annual return (%)"
      ],
      [
        "Y",
        "Years"
      ]
    ],
    "note": "The initial balance compounds monthly at annualReturn/12; recurring deposits are modeled at each month-end. This is a hypothetical scenario, not an S&P 500 return forecast; no inflation, tax, fees, dividends or volatility are modeled. The zero-rate case uses simple addition rather than division by zero."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-04",
    "sources": [
      {
        "name": "OpenStax — Ordinary annuities",
        "url": "https://openstax.org/books/principles-finance/pages/8-2-annuities"
      }
    ],
    "basis": "End-of-month deposits use FV = D × ((1 + i)^n - 1) / i, with i = annual percent / 1200 and n = 12 × years; zero rate uses D × n. Existing savings also grow by (1 + i)^n.",
    "limitations": "Constant nominal rate and equal monthly deposits; excludes taxes, fees and inflation. It is a projection, not a guaranteed return. The entered return is hypothetical, not live S&P 500 data. Fractional month counts are mathematical projections, not an actual payment schedule.",
    "implementationHash": "7b4a8c4cf358c7f38d99eb9ffeec712057ecf8f75526e6aac08f44e77db5b4d7"
  },
  "contract": {
    "compute": "const r=annualReturn/100/12, n=years*12; const grown = initialAmount*Math.pow(1+r,n); const dep = r ? monthlyContribution*((Math.pow(1+r,n)-1)/r) : monthlyContribution*n; const totalInvested = initialAmount + monthlyContribution*n; return { futureValue: grown+dep, totalInvested, growth: grown+dep-totalInvested };",
    "inputs": [
      {
        "name": "initialAmount",
        "type": "number",
        "default": 10000,
        "min": 0,
        "max": 1000000000,
        "step": 500
      },
      {
        "name": "monthlyContribution",
        "type": "number",
        "default": 200,
        "min": 0,
        "max": 10000000,
        "step": 50
      },
      {
        "name": "annualReturn",
        "type": "number",
        "default": 10,
        "min": -20,
        "max": 30,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "years",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 80,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "futureValue",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "totalInvested",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "growth",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
