w3resource

NumPy Financial functions: ipmt() function

numpy.ipmt() function

The ipmt() function is used to compute the interest portion of a payment.

Syntax:

numpy.ipmt(rate, per, nper, pv, fv=0.0, when='end')

Version: 1.15.0

Parameter:

Name Description Required /
Optional
rate Rate of interest as decimal (not per cent) per period
scalar or array_like of shape(M, )
Required
per Interest paid against the loan changes during the life or the loan.
The per is the payment period to calculate the interest amount.
scalar or array_like of shape(M, )
Required
nper Number of compounding periods
scalar or array_like of shape(M, )
Required
pv Present value
scalar or array_like of shape(M, )
Required
fv Future value
scalar or array_like of shape(M, )
Optional
when When payments are due ('begin' (1) or 'end' (0)). Defaults to {'end', 0}.
{{'begin', 1}, {'end', 0}}, {string, int}
Optional

Returns: out : ndarray

Interest portion of payment. If all input is scalar, returns a scalar float. If any input is array_like, returns interest payment for each input element.
If multiple inputs are array_like, they all must have the same shape.

Notes:

The total payment is made up of payment against principal plus interest.

pmt = ppmt + ipmt

NumPy.ipmt() method Example - 1:

>>> import numpy as np
>>> np.allclose(ipmt + ppmt, pmt)

Output:

True

NumPy.ipmt() method Example - 2:

What is the amortization schedule for a 1 year loan of $10000 at 8.5% interest per year compounded monthly?

>>> import numpy as np
>>> principal = 10000.00
>>> per = np.arange(1*12) + 1 # The 'per' variable represents the periods of the loan. Remember that financial equations start the period count at 1!
>>> ipmt = np.ipmt(0.0850/12, per, 1*12, principal)
>>> ppmt = np.ppmt(0.0850/12, per, 1*12, principal)
>>> pmt = np.pmt(0.0850/12, 1*12, principal) # Each element of the sum of the 'ipmt' and 'ppmt' arrays should equal 'pmt'.
>>> fmt = '{0:2d} {1:8.2f} {2:8.2f} {3:8.2f}'
>>> for payment in per:
...     index = payment - 1
...     principal = principal + ppmt[index]
...     print(fmt.format(payment, ppmt[index], ipmt[index], principal))

Output:

 1  -801.36   -70.83  9198.64
 2  -807.04   -65.16  8391.59
 3  -812.76   -59.44  7578.84
 4  -818.51   -53.68  6760.32
 5  -824.31   -47.89  5936.01
 6  -830.15   -42.05  5105.86
 7  -836.03   -36.17  4269.83
 8  -841.95   -30.24  3427.88
 9  -847.92   -24.28  2579.96
10  -853.92   -18.27  1726.03
11  -859.97   -12.23   866.06
12  -866.06    -6.13    -0.00

NumPy.ipmt() method Example - 3:

What is the amortization schedule for a 1 year loan of $10000 at 8.5% interest per year compounded monthly?

>>> import numpy as np
>>> principal = 10000.00
>>> per = np.arange(1*12) + 1 # The 'per' variable represents the periods of the loan. Remember that financial equations start the period count at 1!
>>> ipmt = np.ipmt(0.0850/12, per, 1*12, principal)
>>> ppmt = np.ppmt(0.0850/12, per, 1*12, principal)
>>> pmt = np.pmt(0.0850/12, 1*12, principal) # Each element of the sum of the 'ipmt' and 'ppmt' arrays should equal 'pmt'.
>>> interestpd = np.sum(ipmt)
>>> np.round(interestpd, 2)

Output:

-466.37

NumPy.ipmt() method Example - 4:

What is the amortization schedule for a 1 year loan of $10000 at 8.5% interest per year compounded monthly?

>>> import numpy as np
>>> principal = 10000.00
>>> per = np.arange(1*12) + 1 # The 'per' variable represents the periods of the loan. Remember that financial equations start the period count at 1!
>>> ipmt = np.ipmt(0.0850/12, per, 1*12, principal)
>>> interestpd = np.sum(ipmt)
>>> np.round(interestpd, 3)

Output:

-466.374

Python - NumPy Code Editor:

Previous: ppmt() function
Next: irr() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/numpy/financial-functions/ipmt.php