Python numpy.ipmt()
numpy.ipmt(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
# ipmt() 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 60 %
'''
Solution = np.ipmt(0.6 / 12, 2 * 12, 1 * 12, 10000)
# Here fv = 0 ; Also Default value of fv = 0
print("Solution - ipmt value : ", Solution)
输出:
Solution - ipmt value : 801.4432933339593