def mortgage_payment(principal, annual_rate, years):
monthly_rate = annual_rate / 12 / 100
num_payments = years * 12
payment = principal * (monthly_rate * (1 + monthly_rate)**num_payments) / ((1 + monthly_rate)**num_payments - 1)
return payment
def monthly_cost():
hoa = 88
property_price = 335000
# Duhram rate:https://smartasset.com/taxes/north-carolina-property-tax-calculator#jUMf87tNBM
anual_tax_rate = 1.03 / 100
tax = property_price * anual_tax_rate / 12
insurance = 70
private_mortage_insurance = 0 # PMI, https://www.consumerfinance.gov/ask-cfpb/what-is-private-mortgage-insurance-en-122/
return hoa + tax + insurance + private_mortage_insurance
def fixed_cost(principal, origination_rate, credit_rate):
one_time_cost = 3778
origination = principal * origination_rate / 100
credit = principal * credit_rate / 100
return one_time_cost + origination - credit
def monthly_inflow_cal(principal, fixed, avg_anual_rate):
monthly_return = avg_anual_rate / 12 / 100 * principal
return monthly_return + fixed
loan_amount = 245000
loan_term_years = 30
monthly_rental = 1867.6
capital_anual_return_rate = 8 # Choose 401k return rate as a standard benchmark
# S&P 500 could be higher, ytd 19.96%,
# https://www.marketwatch.com/investing/index/spx, the variance is quite high
# 5.990%, you pay 0.535% origination fee+ closing cost (~$3,778).
# 6.124%, you pay 0.084% origination fee+ closing cost (~$3,778)
# 6.250%, you pay 0.064% origination fee+ closing cost (~$3,778)
# 6.375%, you pay zero origination fee+ closing cost (~$3,778). But the lender
# will credit you 0.262%
# 6.490%, you pay zero origination fee + closing cost (~$3,778). But the lender
# will credit you 0.597%
# [interest_rate, origination_rate, credit_rate]
opt1 = [5.990, 0.535, 0]
opt2 = [6.124, 0.084, 0]
opt3 = [6.250, 0.064, 0]
opt4 = [6.375, 0, 0.262]
opt5 = [6.490, 0, 0.597]
opt_list = [opt1, opt2, opt3, opt4, opt5]
for opt in opt_list:
interest_rate, origination_rate, credit_rate = opt
monthly_payment = mortgage_payment(loan_amount, interest_rate, loan_term_years)
monthly_extra_cost = monthly_cost()
fixed = fixed_cost(loan_amount, origination_rate, credit_rate)
monthly_outflow = monthly_payment + monthly_extra_cost
monthly_inflow = monthly_inflow_cal(loan_amount, monthly_rental, capital_anual_return_rate)
print(f"Interest rate: {interest_rate}%, Monthly payment: {monthly_payment}, Monthly cost: {monthly_extra_cost}, Once time cost: {fixed}, Monthly outflow: {monthly_outflow}, Monthly rental: {monthly_rental}, Monthly inflow: {monthly_inflow}, Monthly net: {monthly_inflow - monthly_outflow}")
Click Run or press shift + ENTER to run code