2016-10-20 72 views
0

我有一個用python編寫的簡單工作年金貸款計算器,與在線計算器相比,它提供了正確的結果。也就是說,每月的金額(什麼部分是利息,什麼是首付金額等)和實際利率(EIR)。它使用兩個numpy的函數,PPMTIPMT按月收費計算正確的實際利率

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! 

回答

0

試試這個(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) 
+0

這定了!只需要使用nPer = 12 *年OOffDownPayment。謝謝! –