[][src]Function finance_solution::net_present_value_schedule_solution

pub fn net_present_value_schedule_solution<C>(
    rates: &[f64],
    cashflows: &[C]
) -> NpvSolution 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 a custom solution struct with detailed information and additional functionality.

Example

let rates = vec![0.034, 0.034, 0.034];
let cashflows = vec![-1000, 300, 400, 500];
let npv = finance_solution::net_present_value_schedule_solution(&rates, &cashflows);
dbg!(npv.print_table());

outputs to terminal:

period   rate   present_value  future_value  investment_value 
------  ------  -------------  ------------  ---------------- 
0       0.0000    -1_000.0000   -1_000.0000       -1_000.0000 
1       0.0340       290.1354      300.0000         -709.8646 
2       0.0340       374.1269      400.0000         -335.7377 
3       0.0340       452.2810      500.0000          116.5433