Calculating Present Value Of Cashflows Using Python And Numpy

Overview:

• Calculating the present value of a sum of money is solving a time value of money problem.
• The function numpy.pv() determines the todays value for one or more future cash flows.
• The interest rate that is used to calculate the present value is also called as discount rate-at what rate a future payment is discounted to calculate its present value.
• As the interest rate is always quoted as annual interest rate while computing the present value using numpy.pv(,)the annual interest rate has to be converted to a rate for the computing period.  To do this, the annual interest rate has to be divided by the compounding frequency.For Example, if the compounding frequency is 12 per year and the annual interest rate is 5%, the monthly interest rate is given by 0.05/12. If the compounding frequency is 4 per year and the annual interest rate is 5%, the quarterly interest rate is given by 0.05/4.

Example 1: Present value of a single future cash flow

 import numpy as np   interestRate            = 0.06;  # Annual interest rate compoundingFrequency    = 2;     # Twice an year futureLumpSum           = 10000;   presentValue            = np.pv(interestRate/compoundingFrequency,                                 compoundingFrequency,                                 0,                                 futureLumpSum,                                 when='end');   print("Interest rate:%2.2f"%interestRate); print("Compounding Frequency:%d"%compoundingFrequency); print("Future value:%5.2f"%futureLumpSum); print("Present value:%5.2f"%presentValue);

Output:

 Interest rate:0.06 Compounding Frequency:2 Future value:10000.00 Present value:-9425.96

Example 2: Present value of multiple future cash flows

 import numpy as np   interestRate            = 0.045;  # Annual interest rate compoundingFrequency    = 4;      # Compounded every quarter periodicCashFlow        = 100;    # Periodic future cash flows  futureValue             = 15000; numberOfYears           = 5;   presentValue            = np.pv(interestRate/compoundingFrequency,                                 compoundingFrequency*numberOfYears,                                 periodicCashFlow,                                 futureValue,                                 when='end');   print("Interest rate:%2.2f"%interestRate); print("Compounding frequency:%d"%compoundingFrequency); print("Periodic cash flow value:%5.2f"%periodicCashFlow);   print("Future value:%5.2f"%futureValue); print("Present value:%5.2f"%presentValue);

Output:

 Interest rate:0.04 Compounding frequency:4 Periodic cash flow value:100.00 Future value:15000.00 Present value:-13774.84