@@ -112,13 +112,13 @@ def fv(rate, nper, pmt, pv, when='end'):
112
112
Examples
113
113
--------
114
114
>>> import numpy as np
115
- >>> import numpy_financial as nf
115
+ >>> import numpy_financial as npf
116
116
117
117
What is the future value after 10 years of saving $100 now, with
118
118
an additional monthly savings of $100. Assume the interest rate is
119
119
5% (annually) compounded monthly?
120
120
121
- >>> nf .fv(0.05/12, 10*12, -100, -100)
121
+ >>> npf .fv(0.05/12, 10*12, -100, -100)
122
122
15692.928894335748
123
123
124
124
By convention, the negative sign represents cash flow out (i.e. money not
@@ -129,7 +129,7 @@ def fv(rate, nper, pmt, pv, when='end'):
129
129
compare different interest rates from the example above.
130
130
131
131
>>> a = np.array((0.05, 0.06, 0.07))/12
132
- >>> nf .fv(a, 10*12, -100, -100)
132
+ >>> npf .fv(a, 10*12, -100, -100)
133
133
array([ 15692.92889434, 16569.87435405, 17509.44688102]) # may vary
134
134
135
135
"""
@@ -218,12 +218,12 @@ def pmt(rate, nper, pv, fv=0, when='end'):
218
218
219
219
Examples
220
220
--------
221
- >>> import numpy_financial as nf
221
+ >>> import numpy_financial as npf
222
222
223
223
What is the monthly payment needed to pay off a $200,000 loan in 15
224
224
years at an annual interest rate of 7.5%?
225
225
226
- >>> nf .pmt(0.075/12, 12*15, 200000)
226
+ >>> npf .pmt(0.075/12, 12*15, 200000)
227
227
-1854.0247200054619
228
228
229
229
In order to pay-off (i.e., have a future-value of 0) the $200,000 obtained
@@ -278,22 +278,22 @@ def nper(rate, pmt, pv, fv=0, when='end'):
278
278
Examples
279
279
--------
280
280
>>> import numpy as np
281
- >>> import numpy_financial as nf
281
+ >>> import numpy_financial as npf
282
282
283
283
If you only had $150/month to pay towards the loan, how long would it take
284
284
to pay-off a loan of $8,000 at 7% annual interest?
285
285
286
- >>> print(np.round(nf .nper(0.07/12, -150, 8000), 5))
286
+ >>> print(np.round(npf .nper(0.07/12, -150, 8000), 5))
287
287
64.07335
288
288
289
289
So, over 64 months would be required to pay off the loan.
290
290
291
291
The same analysis could be done with several different interest rates
292
292
and/or payments and/or total amounts to produce an entire table.
293
293
294
- >>> nf .nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
295
- ... -150 : -99 : 50 ,
296
- ... 8000 : 9001 : 1000]))
294
+ >>> npf .nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
295
+ ... -150 : -99 : 50 ,
296
+ ... 8000 : 9001 : 1000]))
297
297
array([[[ 64.07334877, 74.06368256],
298
298
[108.07548412, 127.99022654]],
299
299
[[ 66.12443902, 76.87897353],
@@ -365,7 +365,7 @@ def ipmt(rate, per, nper, pv, fv=0, when='end'):
365
365
Examples
366
366
--------
367
367
>>> import numpy as np
368
- >>> import numpy_financial as nf
368
+ >>> import numpy_financial as npf
369
369
370
370
What is the amortization schedule for a 1 year loan of $2500 at
371
371
8.24% interest per year compounded monthly?
@@ -376,13 +376,13 @@ def ipmt(rate, per, nper, pv, fv=0, when='end'):
376
376
financial equations start the period count at 1!
377
377
378
378
>>> per = np.arange(1*12) + 1
379
- >>> ipmt = nf .ipmt(0.0824/12, per, 1*12, principal)
380
- >>> ppmt = nf .ppmt(0.0824/12, per, 1*12, principal)
379
+ >>> ipmt = npf .ipmt(0.0824/12, per, 1*12, principal)
380
+ >>> ppmt = npf .ppmt(0.0824/12, per, 1*12, principal)
381
381
382
382
Each element of the sum of the 'ipmt' and 'ppmt' arrays should equal
383
383
'pmt'.
384
384
385
- >>> pmt = nf .pmt(0.0824/12, 1*12, principal)
385
+ >>> pmt = npf .pmt(0.0824/12, 1*12, principal)
386
386
>>> np.allclose(ipmt + ppmt, pmt)
387
387
True
388
388
@@ -533,14 +533,14 @@ def pv(rate, nper, pmt, fv=0, when='end'):
533
533
Examples
534
534
--------
535
535
>>> import numpy as np
536
- >>> import numpy_financial as nf
536
+ >>> import numpy_financial as npf
537
537
538
538
What is the present value (e.g., the initial investment)
539
539
of an investment that needs to total $15692.93
540
540
after 10 years of saving $100 every month? Assume the
541
541
interest rate is 5% (annually) compounded monthly.
542
542
543
- >>> nf .pv(0.05/12, 10*12, -100, 15692.93)
543
+ >>> npf .pv(0.05/12, 10*12, -100, 15692.93)
544
544
-100.00067131625819
545
545
546
546
By convention, the negative sign represents cash flow out
@@ -552,7 +552,7 @@ def pv(rate, nper, pmt, fv=0, when='end'):
552
552
Let's compare different interest rates in the example above:
553
553
554
554
>>> a = np.array((0.05, 0.04, 0.03))/12
555
- >>> nf .pv(a, 10*12, -100, 15692.93)
555
+ >>> npf .pv(a, 10*12, -100, 15692.93)
556
556
array([ -100.00067132, -649.26771385, -1273.78633713]) # may vary
557
557
558
558
So, to end up with the same $15692.93 under the same $100 per month
@@ -718,17 +718,17 @@ def irr(values):
718
718
719
719
Examples
720
720
--------
721
- >>> import numpy_financial as nf
721
+ >>> import numpy_financial as npf
722
722
723
- >>> round(nf .irr([-100, 39, 59, 55, 20]), 5)
723
+ >>> round(npf .irr([-100, 39, 59, 55, 20]), 5)
724
724
0.28095
725
- >>> round(nf .irr([-100, 0, 0, 74]), 5)
725
+ >>> round(npf .irr([-100, 0, 0, 74]), 5)
726
726
-0.0955
727
- >>> round(nf .irr([-100, 100, 0, -7]), 5)
727
+ >>> round(npf .irr([-100, 100, 0, -7]), 5)
728
728
-0.0833
729
- >>> round(nf .irr([-100, 100, 0, 7]), 5)
729
+ >>> round(npf .irr([-100, 100, 0, 7]), 5)
730
730
0.06206
731
- >>> round(nf .irr([-5, 10.5, 1, -8, 1]), 5)
731
+ >>> round(npf .irr([-5, 10.5, 1, -8, 1]), 5)
732
732
0.0886
733
733
734
734
"""
@@ -800,15 +800,15 @@ def npv(rate, values):
800
800
Examples
801
801
--------
802
802
>>> import numpy as np
803
- >>> import numpy_financial as nf
803
+ >>> import numpy_financial as npf
804
804
805
805
Consider a potential project with an initial investment of $40 000 and
806
806
projected cashflows of $5 000, $8 000, $12 000 and $30 000 at the end of
807
807
each period discounted at a rate of 8% per period. To find the project's
808
808
net present value:
809
809
810
810
>>> rate, cashflows = 0.08, [-40_000, 5_000, 8_000, 12_000, 30_000]
811
- >>> nf .npv(rate, cashflows).round(5)
811
+ >>> npf .npv(rate, cashflows).round(5)
812
812
3065.22267
813
813
814
814
It may be preferable to split the projected cashflow into an initial
@@ -818,7 +818,7 @@ def npv(rate, values):
818
818
819
819
>>> initial_cashflow = cashflows[0]
820
820
>>> cashflows[0] = 0
821
- >>> np.round(nf .npv(rate, cashflows) + initial_cashflow, 5)
821
+ >>> np.round(npf .npv(rate, cashflows) + initial_cashflow, 5)
822
822
3065.22267
823
823
824
824
"""
0 commit comments