AppDividend
Latest Code Tutorials

Numpy fv: How to Predict Future Values in Python

Numpy fv() is a financial function that is used to compute the Future Values. The Future value (FV) is the value of an existing asset at a future date based on a projected growth rate. For investors and financial planners, the future value (FV) is essential as they use it to predict how much money an investment made today will be worth in the future.

Numpy fv()

Python numpy fv(rate, nper, pmt, pv, when = ‘end’) is a financial function that helps the user to compute future values. The fv() method takes five parameters and returns the future values after the provided period.

The FV is calculated using the following equation :

fv +pv*(1+rate)**nper +

pmt*(1 + rate*when)/rate*((1 + rate)**nper - 1) == 0

If the rate is equal to 0, then the equation will be :

fv + pv + pmt * nper == 0

Syntax

numpy.fv(rate, nper, pmt, pv, when='end')

The above numpy fv() function takes five arguments.

  1. rate: This is a decimal value that indicates the rate of interest per period. This can be a scalar or an array.
  2. nper: This indicates a total compounding period. This can be a scalar or an array.
  3. pmt: This parameter indicates the fixed payment. This can be a scalar or an array.
  4. pv: This parameter indicates the present value. This can be a scalar or an array.
  5. when: At the beginning (when = {‘begin’, 1}) or the end (when = {‘end’, 0}) of each period.

Return Value

The above function returns a float type value, which indicates the Future Value after the nper period.

Program to show the working of fv() when values are scalar.

# Working of fv() when all values are scalar
import numpy as np

# Assigning values to required variables
rate = 0.15
nper = 10 * 10
pmt = -200
pv = -100

# Now we will calculate Future Value based on the given values
print("Future Value after a period of ", nper, " is :")
print(np.fv(rate, nper, pmt, pv, when='end'))

Output

Future Value after a period of  100  is :
1683181279.3370671

Explanation

In this example, we can see that we have first initialized the values of rate, nper, pmt, and pv, and then we have called np.fv() to calculate the Future Value. 

We can see that, as our all given values are scalar, the result we got is in scalar and float data type.

Program to show the working of fv() when values are in the array.

# Working of fv() when values are in array
import numpy as np

# Assigning values to required variables
rate = np.array((.12, .30, .45))
nper = np.array((100, 120, 50))
pmt = (100, -300, -100)
pv = (-100, 50, -50)

# Now we will calculate Future Value based on the given values
print("Future Value after a period of ", nper, " is :")
print(np.fv(rate, nper, pmt, pv, when='end'))

Output

Future Value after a period of  [100 120  50]  is :
[-6.12488282e+07  4.47636903e+16  3.18657162e+10]

Explanation

In this example, we have initialized the values of rate, nper, pmt, and pv as array values, and then we have called np.fv() to calculate the Future Value. 

As all the given values are in an array, the result we got is in array data type. In this particular example, we have an array size of 3, so the result we got is of size 3.

See also

Numpy place()

Numpy identity()

Numpy roll()

Numpy eye()

Numpy npv()

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.