[−][src]Function finance_solution::net_present_value_schedule
pub fn net_present_value_schedule<C>(rates: &[f64], cashflows: &[C]) -> f64 where
C: Into<f64> + Copy,
Returns the net present value of a schedule of rates and cashflows (can be varying), subtracting the initial investment cost. Returns f64.
Examples
Net Present Value of a series of -$1000 investment which will payback $500 yearly for 10 years.
use finance_solution::*; let (rates, cashflows) = (vec![0.034, 0.089, 0.055], vec![-1000, 200, 300, 500]); // Find the present value of this scenario. let net_present_value = net_present_value_schedule(&rates, &cashflows); // Confirm that the present value is correct to four decimal places (one hundredth of a cent). assert_approx_equal!(-127.8016238, net_present_value); // present_value(0.034, 1, 200): $193.42 // present_value(0.089, 2, 300): $252.97 // present_value(0.055, 3, 500): $425.81 // initial investment: -$1000 // sum of the above: -$127.80 (net present value)