計算每月房貸還款金額
為了確認你負擔得起這間房子,你需要計算對應貸款金額下,每月必須支付的房貸金額。
因為是按月繳納房貸,所以你需要把各個參數都換算成「每月」的等價數值。調整利率時要特別小心,因為利息是複利計算!
要計算每月房貸還款金額,你會使用 numpy 的函式 .pmt(rate, nper, pv),其中:
rate= 每期(每月)利率nper= 貸款存續期間內的期數(月份數)pv= 房貸的總金額
你拿到的是期望貸款金額、年期 30 年、年利率 3.75% 的房貸報價。房貸總金額已存於 mortgage_loan。
年房貸利率已存於 mortgage_rate。
本練習屬於課程
Python 金融概念入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
import numpy as np
# Derive the equivalent monthly mortgage rate from the annual rate
mortgage_rate_periodic = ____
# How many monthly payment periods will there be over 30 years?
mortgage_payment_periods = ____
# Calculate the monthly mortgage payment (multiply by -1 to keep it positive)
periodic_mortgage_payment = -1*np.pmt(____, ____, ____)
print("Monthly Mortgage Payment: " + str(round(periodic_mortgage_payment, 2)))