{
  "name": "CalcMyCompound compound interest test cases",
  "version": "1.1.0",
  "publisher": "Kymata Labs LLC",
  "documentation": "https://www.calcmycompound.com/en/methodology/",
  "license": "CC BY 4.0",
  "conventions": [
    "rate is the nominal annual rate in percent; compounding is periods per year, 0 meaning continuous.",
    "Cash flows happen depositsPerYear times a year (default 12) and earn the equivalent periodic yield (1 + r/n)^(n/c) − 1, or e^(r/c) − 1 when continuous.",
    "timing is end (default) or start of each cash-flow period; yearlyIncrease raises deposits and withdrawals from the second year.",
    "annualFee is a percent of the balance per year, charged each cash-flow period after interest as 1 − (1 − fee)^(1/c); totalInterest is net of fees.",
    "Daily compounding uses a 365-day year. A final partial period grows without a cash flow. Withdrawals never take the balance below zero.",
    "Expected values are full precision to six decimals; compare within 0.000001 relative tolerance."
  ],
  "cases": [
    {
      "id": "lump-annual",
      "description": "Lump sum, annual compounding",
      "input": {
        "principal": 10000,
        "rate": 7,
        "compounding": 1,
        "years": 30
      },
      "expected": {
        "futureValue": 76122.550427,
        "totalDeposits": 10000,
        "totalWithdrawals": 0,
        "totalInterest": 66122.550427,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "lump-monthly",
      "description": "Lump sum, monthly compounding",
      "input": {
        "principal": 10000,
        "rate": 7,
        "compounding": 12,
        "years": 20
      },
      "expected": {
        "futureValue": 40387.38849,
        "totalDeposits": 10000,
        "totalWithdrawals": 0,
        "totalInterest": 30387.38849,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "lump-daily",
      "description": "Lump sum, daily compounding (365-day year)",
      "input": {
        "principal": 10000,
        "rate": 7,
        "compounding": 365,
        "years": 20
      },
      "expected": {
        "futureValue": 40546.556763,
        "totalDeposits": 10000,
        "totalWithdrawals": 0,
        "totalInterest": 30546.556763,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "lump-continuous",
      "description": "Lump sum, continuous compounding",
      "input": {
        "principal": 10000,
        "rate": 7,
        "compounding": 0,
        "years": 20
      },
      "expected": {
        "futureValue": 40551.999668,
        "totalDeposits": 10000,
        "totalWithdrawals": 0,
        "totalInterest": 30551.999668,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "lump-quarterly",
      "description": "Lump sum, quarterly compounding",
      "input": {
        "principal": 5000,
        "rate": 6,
        "compounding": 4,
        "years": 10
      },
      "expected": {
        "futureValue": 9070.092043,
        "totalDeposits": 5000,
        "totalWithdrawals": 0,
        "totalInterest": 4070.092043,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "deposits-end",
      "description": "Monthly deposits at the end of each month",
      "input": {
        "principal": 10000,
        "deposit": 500,
        "rate": 7,
        "compounding": 12,
        "years": 10
      },
      "expected": {
        "futureValue": 106639.017484,
        "totalDeposits": 70000,
        "totalWithdrawals": 0,
        "totalInterest": 36639.017484,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "deposits-start",
      "description": "Monthly deposits at the start of each month",
      "input": {
        "principal": 10000,
        "deposit": 500,
        "rate": 7,
        "compounding": 12,
        "years": 10,
        "timing": "start"
      },
      "expected": {
        "futureValue": 107143.848172,
        "totalDeposits": 70000,
        "totalWithdrawals": 0,
        "totalInterest": 37143.848172,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "deposits-only",
      "description": "Deposits only, no starting balance",
      "input": {
        "deposit": 200,
        "rate": 7,
        "compounding": 12,
        "years": 30
      },
      "expected": {
        "futureValue": 243994.199155,
        "totalDeposits": 72000,
        "totalWithdrawals": 0,
        "totalInterest": 171994.199155,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "deposits-zero-rate",
      "description": "Deposits at a 0% rate",
      "input": {
        "principal": 1000,
        "deposit": 100,
        "rate": 0,
        "compounding": 12,
        "years": 5
      },
      "expected": {
        "futureValue": 7000,
        "totalDeposits": 7000,
        "totalWithdrawals": 0,
        "totalInterest": 0,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "weekly-deposits-daily",
      "description": "Weekly deposits with daily compounding",
      "input": {
        "deposit": 50,
        "rate": 5,
        "compounding": 365,
        "years": 10,
        "depositsPerYear": 52
      },
      "expected": {
        "futureValue": 33716.666554,
        "totalDeposits": 26000,
        "totalWithdrawals": 0,
        "totalInterest": 7716.666554,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "quarterly-deposits-monthly",
      "description": "Quarterly deposits with monthly compounding",
      "input": {
        "principal": 2000,
        "deposit": 600,
        "rate": 4,
        "compounding": 12,
        "years": 15,
        "depositsPerYear": 4
      },
      "expected": {
        "futureValue": 52695.004543,
        "totalDeposits": 38000,
        "totalWithdrawals": 0,
        "totalInterest": 14695.004543,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "yearly-increase",
      "description": "Deposits raised 3% each year",
      "input": {
        "deposit": 300,
        "rate": 7,
        "compounding": 12,
        "years": 30,
        "yearlyIncrease": 3
      },
      "expected": {
        "futureValue": 500147.991641,
        "totalDeposits": 171271.496543,
        "totalWithdrawals": 0,
        "totalInterest": 328876.495099,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "extra-months",
      "description": "Ten years and six months",
      "input": {
        "principal": 10000,
        "deposit": 500,
        "rate": 7,
        "compounding": 12,
        "years": 10,
        "months": 6
      },
      "expected": {
        "futureValue": 113470.330401,
        "totalDeposits": 73000,
        "totalWithdrawals": 0,
        "totalInterest": 40470.330401,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "withdrawals-lasting",
      "description": "Withdrawals that the balance outlasts",
      "input": {
        "principal": 250000,
        "withdrawal": 1200,
        "rate": 5,
        "compounding": 12,
        "years": 30
      },
      "expected": {
        "futureValue": 118225.716068,
        "totalDeposits": 250000,
        "totalWithdrawals": 432000,
        "totalInterest": 300225.716068,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "withdrawals-depleting",
      "description": "Inflation-raised withdrawals that run out",
      "input": {
        "principal": 900000,
        "withdrawal": 3000,
        "rate": 4,
        "compounding": 12,
        "years": 40,
        "yearlyIncrease": 3
      },
      "expected": {
        "futureValue": 0,
        "totalDeposits": 900000,
        "totalWithdrawals": 1669966.486704,
        "totalInterest": 769966.486704,
        "totalFees": 0,
        "depletedAtMonth": 354
      }
    },
    {
      "id": "negative-rate",
      "description": "Deposits at a negative rate",
      "input": {
        "deposit": 100,
        "rate": -2,
        "compounding": 12,
        "years": 1
      },
      "expected": {
        "futureValue": 1189.060883,
        "totalDeposits": 1200,
        "totalWithdrawals": 0,
        "totalInterest": -10.939117,
        "totalFees": 0,
        "depletedAtMonth": null
      }
    },
    {
      "id": "annual-fee",
      "description": "Deposits with a 1% annual fee on the balance",
      "input": {
        "principal": 10000,
        "deposit": 500,
        "rate": 7,
        "compounding": 12,
        "years": 30,
        "annualFee": 1
      },
      "expected": {
        "futureValue": 561290.325847,
        "totalDeposits": 190000,
        "totalWithdrawals": 0,
        "totalInterest": 371290.325847,
        "totalFees": 62639.150115,
        "depletedAtMonth": null
      }
    }
  ]
}
