Python numpy.pmt()
numpy.pmt(rate, nper, pv, fv, when = ‘end’) :这个金融函数帮助用户按照本金和利息计算支付值。
参数 :
rate: [标量或(M, )数组] 每期的利率为小数(不是百分比)。
nper : [标量或(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
or when rate == 0
fv + pv + pmt * nper == 0
代码:
# Python program explaining
# pmt() function
import numpy as np
'''
Question :
monthly payment needed to pay off a $10, 000 loan
in 12 years at an annual interest rate of 10 %
'''
# rate np pv
Solution = np.pmt(0.10 / 12, 12 * 12, 10, 000)
# Here fv = 0 ; Also Default value of fv = 0
print("Solution : ", Solution)
输出:
Solution : -0.1195078262827336