Calculating Future Value of an Investment using Python and numpy

The fv() method of Python library numpy calculates the future value for a series of payments. The Python examples calculates future values for sequence of payments which are made either at the beginning or at the end of each period.

NumPy Updated 20 Mar 2019 2 min read

Overview

  • Future value of money is the value of a sum of money invested now seen at a future date.
  • Furture value can also be calculated for a series of cash flows that will happen over a period of time (starting from now).
  • The numpy.fv() function calculates the Future Value of an investment with additional periodic payments made towards the investment.
  • The numpy.fv() compounds the interest as specified by a compounding frequency. For example, if the compounding frequency is four it means the interest is calculated every quarter using compound interest.
  • The function also supports calculation of future values of payments where the due is during the beginning (i.e., annuity) of or end of each period.

Example 1: Payment Due at the end of each period

python
import numpy as np

initialInvestment       = 500;  # Initial investment

interestRate            = 0.05; # Annual rate of interest

compoundingFrequency    = 4;    # The interest is compounded every 3 months

quarterlyPayment        = 100;  # Payment towards investment

numberOfYears           = 10;   # Future value of total investment upon expiry of this period

futureValue             = np.fv(interestRate/compoundingFrequency,

                                numberOfYears * compoundingFrequency,

                                -quarterlyPayment,

                                -initialInvestment);

print("Initial Investment:%5.2f"%initialInvestment);

print("Interest Rate:%2.2f"%interestRate);

print("Compounding Frequency:%d"%compoundingFrequency);

print("Investment on every quarter:%5.2f"%quarterlyPayment);

print("Investment period in years:%d"%numberOfYears);

print("Value of Investment upon expirty of %d years:%10.2f"%(numberOfYears,futureValue));

Output

Output
Initial Investment:500.00

Interest Rate:0.05

Compounding Frequency:4

Investment on every quarter:100.00

Investment period in years:10

Value of Investment upon expirty of 10 years:   5970.77

##

Example 2: Payment Due at the beginning of each period

python
import numpy as np

initialInvestment       = 1000;  # Initial investment

interestRate            = 0.04;  # Annual rate of interest

compoundingFrequency    = 12;    # The interest is compounded every 3 months

quarterlyPayment        = 100;   # Payment towards investment

numberOfYears           = 5;     # Future value of total investment upon expiry of this period

futureValue             = np.fv(interestRate/compoundingFrequency,

                                numberOfYears * compoundingFrequency,

                                -quarterlyPayment,

                                -initialInvestment,when='begin');

print("Initial Investment:%5.2f"%initialInvestment);

print("Interest Rate:%2.2f"%interestRate);

print("Compounding Frequency:%d"%compoundingFrequency);

print("Invsetment on every quarter:%5.2f"%quarterlyPayment);

print("Investmemt period in years:%d"%numberOfYears);

print("Value of Investmemt upon expirty of %d years:%10.2f"%(numberOfYears,futureValue));

Output

Output
Initial Investment:1000.00

Interest Rate:0.04

Compounding Frequency:12

Invsetment on every quarter:100.00

Investmemt period in years:5

Value of Investmemt upon expirty of 5 years:   7872.99

##