1---
2version: 0.1.0
3precision: 2
4form_title: Retirement Gap Calculator
5form_description: Calculate your pension gap. Enter current income, expected pension, savings and return to see if you're on track.
6form_inputs: Current income|income{€}, Expected pension|pension{€}, Current savings|savings{€}, Monthly savings|monthly_savings{€}, Expected return|return{%}, Retirement age|age{years}, Current age|current_age{years}
7form_outputs: Monthly gap|gap, Capital needed|capital_needed, Projected savings|projected, Gap covered|covered
8---
9# draftply – Retirement Gap Calculator
10# Will your savings be enough to maintain your lifestyle?
11
12# ── Current situation ───────────────────────────────────
13income = 3000 € # current monthly income
14pension = 1800 € # expected monthly pension
15savings = 100000 € # current retirement savings
16monthly_savings = 500 € # monthly retirement contributions
17return_rate = 4 % # expected annual return on investments
18age = 67 years # retirement age
19current_age = 40 years # current age
20
21# ── Calculations ──────────────────────────────────────
22# Monthly gap between income and pension
23gap = income - pension
24
25# Years until retirement
26years_until_retirement = age - current_age
27months_until_retirement = years_until_retirement * 12
28
29# Monthly return rate
30monthly_return = return_rate / 12
31
32# Future value of current savings
33fv_savings = savings * (1 + monthly_return)^months_until_retirement
34
35# Future value of monthly contributions (annuity)
36annuity_factor = ((1 + monthly_return)^months_until_retirement - 1) / monthly_return
37fv_contributions = monthly_savings * annuity_factor
38
39# Total projected savings at retirement
40projected = fv_savings + fv_contributions
41
42# Capital needed to cover the monthly gap
43# Using the 4% rule: you can withdraw 4% annually
44# So capital_needed = gap * 12 / 0.04
45withdrawal_rate = 4 %
46capital_needed = gap * 12 / withdrawal_rate
47
48# Percentage of gap covered
49covered = (projected / capital_needed) * 100
50
51# Monthly amount you can withdraw from projected savings
52monthly_from_savings = projected * withdrawal_rate / 12
53
54# Total monthly income in retirement
55total_retirement_income = pension + monthly_from_savings
56
57# Monthly shortfall
58monthly_shortfall = income - total_retirement_income
59
60# ── Results ─────────────────────────────────────────────
61"Current monthly income": income
62"Expected monthly pension": pension
63"Monthly gap to cover": gap
64
65"Current savings": savings
66"Monthly retirement savings": monthly_savings
67"Years until retirement": years_until_retirement
68
69"Projected savings at retirement": projected
70"Capital needed to cover gap": capital_needed
71"Gap covered": covered
72
73"Monthly from savings (4% rule)": monthly_from_savings
74"Total retirement income": total_retirement_income
75"Monthly shortfall": monthly_shortfall
76
77# What if you save more?
78needed_monthly = (capital_needed - fv_savings) / annuity_factor
79"Additional monthly savings needed": needed_monthly
80