[][src]Struct finance_solution::TvmScheduleSolution

pub struct TvmScheduleSolution { /* fields omitted */ }

A record of a Time Value of Money calculation where the rate may vary by period.

It's the result of calling FutureValueScheduleSolution.tvm_solution or PresentValueScheduleSolution.tvm_solution

Implementations

impl TvmScheduleSolution[src]

pub fn calculated_field(&self) -> &TvmVariable[src]

Returns a variant of TvmVariable showing which value was calculated, either the present value or the future value. To test for the enum variant use functions like TvmVariable::is_future_value.

Examples

let solution = finance_solution::present_value_schedule_solution(&[0.011, 0.012, 0.009], 75_000);
assert!(solution.calculated_field().is_present_value());

pub fn rates(&self) -> &[f64][src]

Returns the periodic rates that were passed to the function.

pub fn periods(&self) -> u32[src]

Returns the number of periods which was derived from the number of rates passed to the function.

Examples

let solution = finance_solution::future_value_schedule_solution(&[0.05, 0.07, 0.05], 100_000);
assert_eq!(3, solution.periods());

pub fn present_value(&self) -> f64[src]

Returns the present value which is a calculated value if this TvmSchedule struct is the result of a call to present_value_schedule_solution and otherwise is one of the input values.

pub fn future_value(&self) -> f64[src]

Returns the future value which is a calculated value if this TvmSchedule struct is the result of a call to future_value_schedule_solution and otherwise is one of the input values.

pub fn series(&self) -> TvmSeries[src]

Calculates the value of an investment after each period.

Examples

Calculate the period-by-period details of a future value calculation. Uses future_value_solution.

// The initial investment is $10,000.12, the interest rate is 1.5% per month, and the
// investment will grow for 24 months using simple compounding.
let solution = finance_solution::future_value_solution(0.015, 24, 10_000.12, false);
dbg!(&solution);

// Calculate the period-by-period details.
let series = solution.series();
dbg!(&series);

// Confirm that we have one entry for the initial value and one entry for each period.
assert_eq!(25, series.len());

// Print the period-by-period numbers in a formatted table.
series.print_table();

// Create a vector with every fourth period.
let filtered_series = series
    .iter()
    .filter(|x| x.period() % 4 == 0)
    .collect::<Vec<_>>();
dbg!(&filtered_series);
assert_eq!(7, filtered_series.len());

Trait Implementations

impl Clone for TvmScheduleSolution[src]

impl Debug for TvmScheduleSolution[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.