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

How to calculate mortgage with a floating rate that compounds monthly

我正在解决这个问题,我给出的浮动利率为 5.1,每月增加 0.1。 (5.1, 5.2 ... 5.9, 6%) 它还每月复利。我得到了 200,000 的初始贷款。每月付款 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']

` 这就是我感到困惑的地方。所以我们从 200,000 开始。它每个月都在减少,然后我们使用该新金额计算新的应付利息。所以它就像一个涉及另一个,我不确定如何将其放入代码中。

我认为我出错的地方在于计算应付利息部分。因为在该代码中我将利率乘以初始贷款值,而不是每个月的值。我只是不确定如何解决这个问题。

简单来说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