[][src]Function finance_solution::net_present_value_solution

pub fn net_present_value_solution<C, I>(
    rate: f64,
    periods: u32,
    initial_investment: I,
    cashflow: C
) -> NpvSolution where
    I: Into<f64> + Copy,
    C: Into<f64> + Copy

Returns the net present value of a future series of constant cashflows and constant rate, subtracting the initial investment cost. Returns a solution struct with additional features..

Related functions:

The net present value annuity formula is:

npv = initial_investment + sum( cashflow / (1 + rate)period )

or

npv = initial_investment + cashflow * ((1. - (1. / (1. + rate)).powf(periods)) / rate)

Arguments

  • rate - The rate at which the investment grows or shrinks per period, expressed as a floating point number. For instance 0.05 would mean 5%. Often appears as r or i in formulas.
  • periods - The number of periods such as quarters or years. Often appears as n or t.
  • cashflow - The value of the constant cashflow (aka payment).
  • initial investment - The value of the initial investment (should be negative, or 0).