월별 주택담보대출 상환액 계산하기
집을 감당할 수 있는지 확인하려면, 그 규모의 대출에 대해 매달 얼마나 상환해야 하는지 계산해야 해요.
매달 상환하므로, 각 매개변수를 월 단위로 변환해야 합니다. 복리로 적용되는 이자율을 조정할 때는 특히 주의하세요!
월별 주택담보대출 상환액을 계산하려면 numpy 함수 .pmt(rate, nper, pv)를 사용합니다. 여기서:
rate= 기간(월별) 이자율nper= 대출 상환 기간 전체의 지급 횟수(개월)pv= 대출 원금(대출 총액)
원하는 금액에 대해 연 3.75%의 30년 만기 모기지 견적을 받았어요. 대출 총액은 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)))