Pension Calculator
Calculate your pension savings at retirement and estimate monthly income using the 4% rule.
Preguntas Frecuentes
Implementación de Código
def pension_projection(
current_age: int,
retirement_age: int,
current_savings: float,
monthly_contribution: float,
annual_return_pct: float,
inflation_pct: float,
) -> dict:
"""Project pension savings and retirement income."""
years = retirement_age - current_age
monthly_rate = annual_return_pct / 100 / 12
months = years * 12
# Future value of current savings (compound growth)
fv_savings = current_savings * (1 + annual_return_pct / 100) ** years
# Future value of monthly contributions (annuity formula)
if monthly_rate > 0:
fv_contributions = monthly_contribution * (
((1 + monthly_rate) ** months - 1) / monthly_rate
)
else:
fv_contributions = monthly_contribution * months
total_savings = fv_savings + fv_contributions
# Monthly retirement income using the 4% rule
annual_income = total_savings * 0.04
monthly_income = annual_income / 12
# Inflation adjustment (today's dollars)
inflation_factor = (1 + inflation_pct / 100) ** years
real_total = total_savings / inflation_factor
real_monthly_income = monthly_income / inflation_factor
return {
"total_savings": round(total_savings, 2),
"monthly_income_nominal": round(monthly_income, 2),
"total_savings_real": round(real_total, 2),
"monthly_income_real": round(real_monthly_income, 2),
"years_to_retirement": years,
}
result = pension_projection(
current_age=35,
retirement_age=65,
current_savings=50_000,
monthly_contribution=500,
annual_return_pct=7.0,
inflation_pct=3.0,
)
for key, value in result.items():
print(f"{key}: {value:,.2f}" if isinstance(value, float) else f"{key}: {value}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.