🛠️ToolsShed

NPV & IRR 计算器

计算投资的净现值(NPV)和内部收益率(IRR)。

Year 1
Year 2
Year 3

常见问题

代码实现

def calculate_npv(discount_rate, initial_investment, cash_flows):
    """
    discount_rate: annual rate as decimal (e.g., 0.10 for 10%)
    initial_investment: upfront cost (positive number)
    cash_flows: list of annual cash flows starting at year 1
    """
    pv_sum = sum(cf / (1 + discount_rate) ** (t + 1)
                 for t, cf in enumerate(cash_flows))
    npv = pv_sum - initial_investment
    return npv

# Example: $50,000 investment, 10% discount rate, 5-year project
initial_investment = 50000
discount_rate = 0.10
cash_flows = [15000, 18000, 20000, 22000, 25000]

npv = calculate_npv(discount_rate, initial_investment, cash_flows)
print(f"NPV: ${npv:,.2f}")
print("Decision:", "Accept (NPV > 0)" if npv > 0 else "Reject (NPV < 0)")

Comments & Feedback

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