Struct NpvSolution

Source
pub struct NpvSolution { /* private fields */ }
Expand description

The custom solution information of a NPV scenario. The struct values are immutable by the user of the library.

Implementations§

Source§

impl NpvSolution

Source

pub fn new( rates: Vec<f64>, periods: u32, initial_investment: f64, cashflows: Vec<f64>, sum_of_cashflows: f64, sum_of_discounted_cashflows: f64, net_present_value: f64, ) -> Self

Create a new instance of the struct

Source

pub fn series(&self) -> NpvSeries

Source

pub fn rate_avg(&self) -> f64

Call rate_avg on a NpvSolution to get the simple average rate of a schedule;

Source

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

Returns the rate schedule

Source

pub fn periods(&self) -> u32

Returns the number of periods as u32.

Source

pub fn initial_investment(&self) -> f64

Returns the initial investment as f64.

Source

pub fn cashflows(&self) -> &[f64]

Returns a Vec of the cashflows.

Source

pub fn sum_of_cashflows(&self) -> f64

Returns the sum of the cashflows at their future value.

Source

pub fn sum_of_discounted_cashflows(&self) -> f64

Returns the sum of the cashflows at their present value.

Source

pub fn net_present_value(&self) -> f64

Returns the net present value as f64.

Source

pub fn npv(&self) -> f64

Alias for net_present_value()

Source

pub fn print_table(&self)

Pretty-print a table of the calculations at each period for visual analysis.

Source

pub fn print_table_locale(&self, locale: &Locale, precision: usize)

Pretty-print a table of the calculations at each period for visual analysis, and provide a Locale for monetary formatting and preferred decimal precision.

Source

pub fn max_discounted_cashflow(&self) -> f64

Return the max discounted cashflow (present value of the cashflow)

Source

pub fn min_discounted_cashflow(&self) -> f64

Return the min discounted cashflow (present value of the cashflow)

Trait Implementations§

Source§

impl Debug for NpvSolution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.