pub struct TvmScheduleSolution { /* private fields */ }
Expand description
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§
Source§impl TvmScheduleSolution
impl TvmScheduleSolution
Sourcepub fn calculated_field(&self) -> &TvmVariable
pub fn calculated_field(&self) -> &TvmVariable
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());
Sourcepub fn periods(&self) -> u32
pub fn periods(&self) -> u32
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());
Sourcepub fn present_value(&self) -> f64
pub fn present_value(&self) -> f64
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.
Sourcepub fn future_value(&self) -> f64
pub fn future_value(&self) -> f64
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.
Sourcepub fn series(&self) -> TvmSeries
pub fn series(&self) -> TvmSeries
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§
Source§impl Clone for TvmScheduleSolution
impl Clone for TvmScheduleSolution
Source§fn clone(&self) -> TvmScheduleSolution
fn clone(&self) -> TvmScheduleSolution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more