Expand description
Time-value-of-money equations without level payments: present value, future value, rate, and periods (simple and continuous compounding, fixed rate or rate schedules).
§Error handling (v0.1+)
Public entry points return crate::FinanceResult. Invalid rates (e.g. less than −100% per
period), non-finite amounts, and unsolvable sign combinations produce
crate::FinanceError — they do not panic.
use finance_solution::{future_value, FinanceResult};
fn demo() -> FinanceResult<f64> {
future_value(0.05, 10, -1_000.0, false)
}
debug_assert!(demo().is_ok());§Compounding
Pass Compounding::Periodic (or false via From) for discrete compounding, or
Compounding::Continuous (or true) for continuous compounding.
Modules§
- future_
value - Future value calculations. Given an initial investment amount, a number of periods such as periods, and fixed or varying interest rates, what is the value of the investment at the end?
- periods
- Number of periods calculations. Given a periodic rate, present value, and future value, find the number of periods needed to satisfy the equation.
- present_
value - Present value calculations. Given a final amount, a number of periods such as years, and fixed or varying interest rates, what is the current value?
- rate
- Periodic rate calculations. Given an initial investment amount, a final amount, and a number of periods what does the rate per period need to be?
Structs§
- TvmPeriod
- The value of an investment at the end of a given period, part of a Time Value of Money calculation.
- TvmSchedule
Solution - A record of a Time Value of Money calculation where the rate may vary by period.
- TvmSeries
- TvmSolution
Enums§
- Compounding
- How interest compounds in a TVM calculation.
- TvmVariable
- Enumeration used for the
calculated_fieldfield inTvmSolutionand schedule solutions to track what was calculated: periodic rate, number of periods, present value, or future value.
Functions§
- future_
value - Returns the value of an investment after it has grown or shrunk over time, using a fixed rate.
- future_
value_ schedule - Calculates a future value based on rates that change for each period.
- future_
value_ schedule_ solution - Calculates a future value based on rates that change for each period, returning a struct with all of the inputs and results.
- future_
value_ solution - Calculates the value of an investment after it has grown or shrunk over time and returns a struct with the inputs and the calculated value. This is used for keeping track of a collection of financial scenarios so that they can be examined later.
- periods
- Returns the number of periods given a periodic rate along with the present and future values, using simple compounding.
- periods_
solution - Calculates the number of periods given a periodic rate along with the present and future values using simple compounding; and builds a struct with the input values, an explanation of the formula, and the option to calculate the period-by-period values.
- present_
value - Returns the current value of a future amount using a fixed rate.
- present_
value_ schedule - Calculates a present value based on rates that change for each period.
- present_
value_ schedule_ solution - Calculates a present value based on rates that change for each period and returns a struct with the inputs and the calculated value.
- present_
value_ solution - Calculates the current value of a future amount using a fixed rate and returns a struct with the inputs and the calculated value. This is used for keeping track of a collection of financial scenarios so that they can be examined later.
- rate
- Returns the periodic rate of an investment given the number of periods along with the present and future values.
- rate_
solution - Returns the periodic rate of an investment given the number of periods along with the present and future values.