1---
2version: 0.1.0
3precision: 2
4form_title: Rent vs Buy – What's cheaper?
5form_description: Compare the monthly cost of renting and owning — and see when the equity you build overtakes the extra money owning costs you.
6form_inputs: Home price|price{€}, Down payment|down_payment{€}, Mortgage rate|rate{%}, Mortgage term (years)|term, Monthly rent|rent{€}, Property tax per month|property_tax{€}, Maintenance per year|maintenance_pct{%}
7form_outputs: Monthly mortgage|mortgage, Total monthly buy cost|buy_cost, Break-even years|break_even, Net position after 10 years|net_10yr
8form_plots: 1
9---
10# draftply – Rent vs Buy Calculator
11# Is it cheaper to buy or rent? Renting wins on cash flow; owning wins by
12# building equity. This notebook works out when the second overtakes the first.
13
14# ── Purchase details ──────────────────────────────────
15price = 500000 € # home price
16down_payment = 30000 €
17loan = price - down_payment
18rate = 3.5 % # annual mortgage rate
19term = 25 # mortgage term (years)
20
21# ── Monthly costs ────────────────────────────────────
22monthly_rate = rate / 12
23months = term * 12
24
25# Monthly mortgage payment (annuity formula)
26mortgage = loan * monthly_rate * (1 + monthly_rate)^months / ((1 + monthly_rate)^months - 1)
27
28# Additional costs for owning
29property_tax = 200 €
30maintenance_pct = 0.5 %
31maintenance = price * maintenance_pct / 12
32
33# Total monthly cost of owning
34buy_cost = mortgage + property_tax + maintenance
35
36# ── Rent details ─────────────────────────────────────
37rent = 1800 €
38
39# ── Comparison ────────────────────────────────────────
40# Positive = renting is cheaper month to month (the usual case).
41monthly_extra = buy_cost - rent
42
43# What is left of the loan after N years (annuity amortisation)
44remaining(years) = loan * (1 + monthly_rate)^(years * 12) - mortgage * ((1 + monthly_rate)^(years * 12) - 1) / monthly_rate
45
46# Equity built = the part of the loan you have paid off. The down payment is
47# left out on purpose: it is capital you moved, not money you gained.
48equity(years) = loan - remaining(years)
49
50# The extra cash owning has cost you by then
51extra_cost(years) = monthly_extra * years * 12
52
53# Net position: equity built minus what it cost extra. Above zero, buying is
54# ahead — the property value itself is left out, so this is the cautious view.
55net_position(years) = equity(years) - extra_cost(years)
56
57# Break-even: the first full year the net position turns positive. A result
58# beyond the mortgage term means owning never catches up within it — try it
59# with a lower rent and watch the year climb.
60def break_even_year():
61 y = 1
62 while y <= term and net_position(y) < 0 €:
63 y = y + 1
64 return y
65
66break_even = break_even_year()
67net_10yr = net_position(10)
68
69# ── Results ──────────────────────────────────────────
70"Monthly mortgage payment": mortgage
71"Total monthly owning cost": buy_cost
72"Owning costs more per month": monthly_extra
73
74"Buying is ahead from year": break_even
75
76"Equity after 10 years": equity(10)
77"Extra cost after 10 years": extra_cost(10)
78"Net position after 10 years": net_10yr
79
80"Equity after 20 years": equity(20)
81"Net position after 20 years": net_position(20)
82
83# ── Visualization ─────────────────────────────────────
84# Net position over time: below zero renting is ahead, above zero owning is.
85plot(net_position(x), 0..25, "Rent vs Buy", "Years", "€", "Equity minus the extra cost of owning")
86