-
-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Description
The numpy.ipmt and numpy.ppmt functions seem to misbehave when per=1. The ipmt+ppmt still equals the result of numpy.pmt, but as you can see below, ipmt results in 0 for per=1, while ppmt equals the full amount of principal+interest.
I noticed that https://github.com/numpy/numpy/blob/master/numpy/lib/financial.py contains an exception for per=1, but I do not think that should be there:
ipmt = np.where(np.logical_and(when == 1, per == 1), 0.0, ipmt)
# Principal calculation (notice second line)
numpy.ppmt(rate=0.001988079518355057, per=0, nper=360, pv=300000, fv=0, when="begin")=-568.922801885
numpy.ppmt(rate=0.001988079518355057, per=1, nper=360, pv=300000, fv=0, when="begin")=-1165.29433577
numpy.ppmt(rate=0.001988079518355057, per=2, nper=360, pv=300000, fv=0, when="begin")=-571.18717807
numpy.ppmt(rate=0.001988079518355057, per=3, nper=360, pv=300000, fv=0, when="begin")=-572.3227436
# ...etc
# Interest calculation (notice second line)
numpy.ipmt(rate=0.001988079518355057, per=0, nper=360, pv=300000, fv=0, when="begin")=-596.37153388933
numpy.ipmt(rate=0.001988079518355057, per=1, nper=360, pv=300000, fv=0, when="begin")=0.0
numpy.ipmt(rate=0.001988079518355057, per=2, nper=360, pv=300000, fv=0, when="begin")=-594.1071577047084
numpy.ipmt(rate=0.001988079518355057, per=3, nper=360, pv=300000, fv=0, when="begin")=-592.9715921748406
# ...etc
Metadata
Metadata
Assignees
Labels
No labels