Skip to content

Calculating Compound Interest

This API calculates compound interest over multiple years.

HTTP POST Form Example

principal:

yearly_contribution:

contributions_per_year:

annual_interest_rate:

yearly_inflation:

years:

HTTP GET URL Example:

Copy and paste this URL into a browser window.

Call API - appreciation intrest rate

Sample Result

The API returns a dictionary of key-values, where key is the year and value is a dollar value accumulated.

{

"1": 12368.6,

"2": 25576.05,

"3": 39679.24,

"4": 54738.93,

"5": 70819.98,

...

"30": 1123531.8

}

Parameters

https://us-east1-aiapi-225619.cloudfunctions.net/financial_compound_interest

Principal

float (e.g. 123.01)

This is the amount you start the calculation with, for example amount already invested.

?principal=0

yearly_contribution

float (e.g. 123.01)

This is a total you are planning to invest every subsequent year.

&yearly_contribution=12000

contributions_per_year

Int (e.g. 12, 4, 1, default is 12)

This is how often in a year you will contribute.

  • 12 for every month (at the end of the month)

  • 4 for quarterly (at the end of the quarter)

  • 1 for once a year (at the end of the year)

&contributions_per_year=12

annual_interest_rate

float (e.g. default 9.8)

The annual interest rate, the 9.8% is a default as this is average rate of stock market S&P500.

&annual_interest_rate=9.8

yearly_inflation

float (e.g. default 3.22)

The annual inflation in your country, in USA it is on average 3.22% per year. Which means whatever interest rate you made, you have to take out 3.22% to receive comparable dollar amount.

&yearly_inflation=3.22

years

Int (e.g. 5, 10, 20, 30, default is 20)

Amount of years you will want to accumulate your interests.

&years=30

Depreciation Example

You can also calculate how long can you spend your millions.

Call API - depreciation example

In this example you start with $1,000,000

and take out $100,000 every year.

The calculation shows you will run out of money after 16 years.

{

"1": 964749.5,

"2": 927108.27,

"3": 886914.17,

...

"16": 34585.88,

"17": -66140.1,

}