Let's model the total amount of money spent at time t when buying
According to wikipedia :
Loan payment
The most typical loan payment type is the fully amortizing payment in which each monthly rate has the same value over time.[4]
The fixed monthly payment P for a loan of L for n months and a monthly interest rate c is:
$P = L \cdot \frac{c\,(1 + c)^n}{(1 + c)^n - 1}$
The above calculates the future value FV of an investment whose present value is PV accruing interest at a fixed interest rate i for n periods.
$FV = PV ( 1+i )^n\,$
In [78]:
house_price = 100e3
down_payment = 20e3
avg_house_price_increase = 0.03
avg_rent_increase = 0.01
investment_return = 0.02
mortgage_rate_apr = 5.00
mortgage_duration = 25 * 12
inflation_rate = 0.0025
stamp_duty = .05
maintenance = 83.33
utilities = 150
rent = 800
renting_deposit = rent * 2
simulation_duration = mortgage_duration
In [81]:
%matplotlib inline
import matplotlib.pyplot as plt
import math
def mortgage_cost():
loan_amount = house_price - down_payment
#c = (math.pow(loan_apr, 1./12.)-1)
c = mortgage_rate_apr / 12. / 100.
monthly_payment = loan_amount * ((c * (1+c)**mortgage_duration) / ((1+c)**mortgage_duration - 1))
for i in range(mortgage_duration):
yield (down_payment + monthly_payment * i)
def buying_model():
house_value = house_price
house_resell_value = 0
one_time_cost = stamp_duty * house_value
maintenance_per_month = maintenance
utilities_per_month = utilities
recurring_cost = 0
for i, month_cost in enumerate(mortgage_cost()):
house_resell_value += (1/float(mortgage_duration)) * house_value
house_resell_profit = house_resell_value - house_resell_value * stamp_duty
recurring_cost += maintenance_per_month + utilities_per_month
if i % 12 == 0 and i > 0:
house_value += house_value * avg_house_price_increase
maintenance_per_month += maintenance_per_month * inflation_rate
utilities_per_month += utilities_per_month * inflation_rate
yield - month_cost - one_time_cost - recurring_cost #+ house_resell_profit
def money_spent_renting(rent):
total_rent_cost = 0
for i in range(simulation_duration):
total_rent_cost += rent
if i % 12 == 0 and i > 0:
rent += rent * avg_rent_increase
yield total_rent_cost
def renting_model():
investment = down_payment - renting_deposit
utilities_per_month = utilities
utilities_cost = 0
for i, month_cost in enumerate(money_spent_renting(rent)):
utilities_cost += utilities_per_month
if i % 12 == 0 and i > 0:
investment += investment * investment_return
utilities_per_month += utilities_per_month * inflation_rate
yield - month_cost - utilities_cost + investment
plt.plot(range(simulation_duration), list(buying_model()), 'r')
plt.plot(range(simulation_duration), list(renting_model()), 'b')
plt.title("The model")
Out[81]:
In [68]: