如何计算每月复利的浮动利率抵押贷款



我正在解决这个问题,我给出了5.1的浮动利率,每月增加0.1。(5.1, 5.2…5.9, 6%)它还会按月复利。我的初始贷款是20万。每月支付1000美元,我想解决他们每个月欠多少钱。

我使用Pandas系列来保持增长速度。我很难创建一个有用的函数。如有任何建议,不胜感激。

这是我的。

df = pd.DataFrame(51*np.ones(100) +  np.arange(100))
df = df.rename(columns={0:'monthly rate'})
df['monthly rate'] = df['monthly rate']  /10/100 /12
df['monthly payment'] = 1000
df['interest due'] = df['monthly rate'] * 200000
df['mortgage decreasing'] = df['interest due'] - df['monthly payment']

'这就是我困惑的地方。我们从20万开始。它每个月都在减少,然后我们用这个减少的金额来计算新的到期利息。所以这就像一个涉及到另一个,我不知道如何把它写进代码。

我想我错在计算利息部分。因为在这段代码中,我将利率乘以初始贷款价值,而不是每个月的价值。我只是不知道如何解决这个问题。

在普通Python中,您可以像这样模拟它:

loan = 200000
interest = 0.051
payment = 1000
interest_change = 0.001
month = 1
while month < 37:
# In real life banks calculates interest per day, not 1/12 of year
month_interest = loan * interest/12
new_loan = loan+month_interest-payment
print ("%s: %.2f t +%.2f (%.2f %%) t-%s t -> %.2f  " % (month,loan,month_interest, interest*100, payment, new_loan))
loan = new_loan
interest += interest_change
month += 1
if loan < 0:
break

最新更新