🛠️ToolsShed

Calculadora FIRE

Calcule seu número de independência financeira e anos para a aposentadoria antecipada.

Perguntas Frequentes

Implementação de Código

import math

def fire_number(annual_expenses, withdrawal_rate=0.04):
    """FIRE number using the safe withdrawal rate rule."""
    return round(annual_expenses / withdrawal_rate, 2)

def years_to_fire(current_savings, annual_savings, fire_target, annual_return=0.07):
    """Estimate years to reach FIRE using compound growth formula."""
    r = annual_return
    if r == 0:
        return (fire_target - current_savings) / annual_savings
    # FV = PV*(1+r)^n + PMT*((1+r)^n - 1)/r = fire_target
    # Solve numerically year by year
    portfolio = current_savings
    for year in range(1, 1000):
        portfolio = portfolio * (1 + r) + annual_savings
        if portfolio >= fire_target:
            return year
    return float("inf")

# Example
annual_expenses = 40000
target = fire_number(annual_expenses)         # 1,000,000
print(f"FIRE Number: ${target:,.0f}")
years = years_to_fire(50000, 24000, target)   # ~19 years
print(f"Years to FIRE: {years}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.