summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/financial.py6
-rw-r--r--numpy/lib/tests/test_financial.py38
2 files changed, 23 insertions, 21 deletions
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py
index c5d6d27e7..5bb4a3af7 100644
--- a/numpy/lib/financial.py
+++ b/numpy/lib/financial.py
@@ -139,11 +139,13 @@ array([[[ 32.58497782, 38.57048452],
"""
def ipmt(rate, per, nper, pv, fv=0.0, when='end'):
+ total = pmt(rate, nper, pv, fv, when)
+ # Now, compute the nth step in the amortization
raise NotImplementedError
-
def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
- raise NotImplementedError
+ total = pmt(rate, nper, pv, fv, when)
+ return total - ipmt(rate, per, nper, pv, fv, when)
def pv(rate, nper, pmt, fv=0.0, when='end'):
"""Number of periods found by solving the equation
diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py
index c3153ffb9..ee38c10dc 100644
--- a/numpy/lib/tests/test_financial.py
+++ b/numpy/lib/tests/test_financial.py
@@ -1,32 +1,32 @@
"""
-from numpy import *
+>>> from numpy import rate, irr, pv, fv, pmt, nper, npv, mirr, round
->>> rate(10,0,-3500,10000)
-0.11069085371426901
+>>> round(rate(10,0,-3500,10000),4)==0.1107
+True
->>> irr([-150000, 15000, 25000, 35000, 45000, 60000])
-0.052432888859414106
+>>> round(irr([-150000, 15000, 25000, 35000, 45000, 60000]),4)==0.0524
+True
->>> pv(0.07,20,12000,0)
--127128.17094619398
+>>> round(pv(0.07,20,12000,0),2) == -127128.17
+True
->>> fv(0.075, 20, -2000,0,0)
-86609.362673042924
+>>> round(fv(0.075, 20, -2000,0,0),2) == 86609.36
+True
->>> pmt(0.08/12,5*12,15000)
--304.14591432620773
+>>> round(pmt(0.08/12,5*12,15000),3) == -304.146
+True
->>> nper(0.075,-2000,0,100000.)
-21.544944197323336
+>>> round(nper(0.075,-2000,0,100000.),2) == 21.54
+True
->>> npv(0.05,[-15000,1500,2500,3500,4500,6000])
-117.04271900089589
+>>> round(npv(0.05,[-15000,1500,2500,3500,4500,6000]),2) == 117.04
+True
->>> mirr([-4500,-800,800,800,600,600,800,800,700,3000],0.08,0.055)
-0.066471183500200537
+>>> round(mirr([-4500,-800,800,800,600,600,800,800,700,3000],0.08,0.055),4) == 0.0665
+True
->>> mirr([-120000,39000,30000,21000,37000,46000],0.10,0.12)
-0.13439316981387006
+>>> round(mirr([-120000,39000,30000,21000,37000,46000],0.10,0.12),4)==0.1344
+True
"""
from numpy.testing import *