Python numpy.nper()
numpy.pmt(rate, pmt, pv, fv, when = ‘end’) :这个财务函数帮助用户计算定期付款的数量。
参数 :
rate :[标量或(M,)数组] 每期的利率为小数(不是百分比)。
pmt :[标量或(M,)阵列] 支付值
fv :[标量或(M, )数组] 未来值
pv :[标量或(M, )数组] 现值
when :在每个周期的开始(when = {‘begin’, 1})或结束(when = {‘end’, 0})。默认是{‘end’, 0}。
返回 :定期付款的数量。
求解方程:
fv + pv*(1+rate)nper + pmt*(1+rate*when)/rate*((1+rate)nper – 1) == 0
或 当率==0时
fv + pv + pmt * nper == 0
代码:
# Python program explaining
# pmt() function
import numpy as np
'''
Question :
how much time would it take to pay-off a loan of
10, 000 at 10 % annual rate of interest, if we had 100 to pay each month ?
'''
# rate pmt pv
Solution = np.nper(0.1 / 12, -100, 10000)
# Here fv = 0 ; Also Default value of fv = 0
print("Solution - No. of periods : % f months" %(Solution))
输出:
Solution - No. of periods : 215.905777 months