pub fn amort_schedule<T: FloatLike>(
rate: T,
nper: u32,
principal: T,
pmt: T,
round: Option<(u32, RoundingMode, T)>,
) -> Vec<AmortizationPeriod<T>>Expand description
Amortization Schedule
Calculates the amortization schedule for a loan or mortgage.
The amortization schedule includes a series of payments that are applied to both principal and interest. Each payment reduces the principal balance and pays interest charges based on the remaining balance and the interest rate.
§Feature
This function requires the std feature to be enabled as it uses std::Vec. amort_schedule_into
can be used in no_std environments as any allocation is done by the caller.
§Arguments
rate- The interest rate per periodnper- The total number of payment periodsprincipal- The present value or principal amount of the loan (should be positive as cash inflow for a mortgage/loan)pmt- The payment amount per period (should be negative as cash outflow, can be calculated usingpmtfunction)round(optional) - A tuple specifying the number of decimal places and a rounding strategy for the amounts(dp, RoundingMode), default is no rounding of calculations. The final principal payment is adjusted to zero out the remaining balance if rounding is enabled.
§Returns
- A vector of
AmortizationPeriodinstances representing each period in the amortization schedule.
§Examples
- 5% rate, 30 year term (360 months), $1,000,000 loan, $4,000 monthly payment
use rust_finprim::amort_dep_tax::amort_schedule;
use rust_finprim::tvm::pmt;
let rate = 0.05 / 12.0; // Monthly rate
let nper = 30 * 12;
let principal = 1_000_000.0;
let pmt = pmt(rate, nper.into(), principal, None, None);
let schedule = amort_schedule(rate, nper, principal, pmt, None);