我有一个用python编写的简单的工作年金贷款计算器,与在线计算器相比,它提供正确的结果。即,每月金额(什么部分是利息,什么是首付金额等)和实际利率(EIR)。它使用两个numpy函数,ppmt和ipmt
loanAmount = 100000
monthlyIntRate = 2.5 / 12
effectiveIntRate = 100 * ((1 + monthlyIntRate/100.)**12 - 1)
但是,当我将每月费用添加到付款中时,我的EIR会发生变化,但不再等于在线贷款计算器给出的答案。
monthlyFee = -5
monthlyIntToBePaid = np.ipmt(rate, per, nPer, loanAmount)
monthDownPay = np.ppmt(rate, per, nPer, loanAmount)
amountDue = monthlyInt + monthDownPay + monthlyFee
其他一切,仍然是完全一致的。我认为我的公式有点不错,但我想知道一种更好的方法!
effectiveIntRate = 100 * ((1+ monthlyIntRate/100.)**12 - 1)
effectiveIntRate += 100 * monthlyFee*12*2./loanAmount # <-- this line!
最佳答案
尝试以下操作(使用IRR查找费用后的汇率):
nPer=12
rate=monthlyIntRate/100.
Monthpay=np.pmt(rate, nPer, loanAmount, fv=0)
amountDue = Monthpay + monthlyFee
effectiveIntRate = 100 * ((1+ monthlyIntRate/100.)**12 - 1)
#effectiveIntRate += 100 * monthlyFee*12*2./loanAmount # <-- this line!
monthpays = [-amountDue] * nPer
monthpaysf=[-loanAmount] + monthpays
efratem=np.irr(monthpaysf)
effectiveIntRateF = 100 * ((1 + efratem)**12 - 1)
print(efratem*100,effectiveIntRateF)
(0.21749271256861213, 2.6413600327578557)