计算每月按揭还款额
为了确保您负担得起这套房,您需要计算在该贷款金额下每月需要偿还的按揭金额。
由于您是按月还款,需要将各个参数转换为按月口径。调整利率时要格外小心,因为这是复利计算!
要计算每月按揭还款额,您将使用 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)))