Function rust_finprim::tvm::pmt
source · pub fn pmt(
rate: Decimal,
nper: Decimal,
pv: Decimal,
fv: Option<Decimal>,
due: Option<bool>
) -> Decimal
Expand description
PMT - Payment
General payment calculation, similar to the Excel PMT
function. Commonly used for loan and mortgage calculations.
The due
parameter expresses whether the annuity type is an ordinary annuity (false and the default) or an annuity due (true),
Excel provides this parameter as type
with 0 for ordinary annuity and 1 for annuity due.
The payment (PMT) is the amount of money that is paid or received at each period in an annuity.
§Arguments
rate
- The interest rate per periodnper
- The number of compounding periodspv
- The present value of a series of cash flows or principal amountfv
(optional) - The future valuedue
(optional) - The timing of the payment (false = end of period, true = beginning of period), default is false (ordinary annuity)
At least one of pv
or fv
should be non-zero.
§Returns
- The payment amount (PMT)
§Example
- 5% interest rate
- 10 compounding periods
- $1000 present value
- $100 future value
use rust_decimal_macros::*;
use rust_finprim::tvm::pmt;
let rate = dec!(0.05); let nper = dec!(10); let pv = dec!(1000); let fv = dec!(100);
pmt(rate, nper, pv, Some(fv), None);
§Formula
The payment amount (PMT) is calculated using the formula for the present value of an annuity. The formula is: $$PMT = \frac{r(PV (r+1)^n - FV)}{(r+1)^n -1}$$
Where:
- \(r\) = interest rate per period
- \(PV\) = present value of a series of cash flows or principal amount
- \(FV\) = future value
- \(n\) = number of compounding periods