Calculating the duration to complete a loan

The number of periodic payments to be made towards an existing loan can be calculated using the nper() function of numpy with the values of interest rate, outstanding loan amount and the periodic payment amount .

NumPy Updated 17 Apr 2020 1 min read

Overview

  • Given the values for the interest rate, payment amount(due, installment, periodic payment amount) and the net present value towards a loan, the number of payments required to complete the loan payment is calculated by the nper() function of numpy.

Example

python
# Example Python program that calculates

# the number of payments required to complete

# the payment for a loan

import numpy as np

compoundingFrequency    = 1; # Once in 12 months

interestRatepercent     = 7;

outstandingLoanAmount   = 75000;

periodicPayment         = 1200;

numberOfPayments    = np.nper((interestRatepercent/100)/12, -periodicPayment,

                              outstandingLoanAmount);

paymentMonths       = np.round(numberOfPayments, 3);

print("Number of months required to complete the loan payment:");

print(paymentMonths);

Output

Output
Number of months required to complete the loan payment:

77.965