🛠️ToolsShed

储蓄目标计算器

计算每月需要储蓄多少才能实现您的财务目标。

储蓄目标计算器帮助您精确算出每月需要储蓄多少才能在特定日期前达到财务目标。无论您是在为度假、首付款、应急基金还是重大购买而储蓄,此工具都能将您的目标转化为具体可行的月度储蓄金额。

输入目标金额、当前储蓄、储蓄账户的年回报率和目标日期。计算器会告诉您所需的每月供款,并显示最终余额中有多少来自您的供款以及利息收益。

您也可以反向解决问题:输入每月可以储蓄的金额,看看达到目标需要多长时间。看到时间线使抽象目标变得具体,帮助您决定是否调整目标金额、月度储蓄或目标日期。

常见问题

代码实现

def monthly_savings_needed(
    goal: float,
    current_savings: float,
    months: int,
    annual_rate: float = 0
) -> float:
    """Calculate monthly deposit needed to reach a savings goal."""
    if annual_rate == 0:
        return (goal - current_savings) / months
    r = annual_rate / 100 / 12  # monthly rate
    fv_current = current_savings * (1 + r) ** months
    remaining = goal - fv_current
    if remaining <= 0:
        return 0
    pmt = remaining / (((1 + r) ** months - 1) / r)
    return pmt

# Example: save $10,000 in 24 months with 4% annual interest
monthly = monthly_savings_needed(
    goal=10000,
    current_savings=1000,
    months=24,
    annual_rate=4
)
print(f"Monthly deposit needed: ${monthly:.2f}")

# Show total contributions vs interest earned
total_contributions = monthly * 24 + 1000
print(f"Total contributions: ${total_contributions:.2f}")
print(f"Interest earned: ${10000 - total_contributions:.2f}")

Comments & Feedback

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