Function rust_finprim::tvm::pv

source ·
pub fn pv(
    rate: Decimal,
    nper: Decimal,
    pmt: Decimal,
    fv: Option<Decimal>,
    due: Option<bool>
) -> Decimal
Expand description

PV - Present Value

A general present value calculation, similar to the Excel PV function. Commonly used for bond pricing and annuity 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 present value (PV) is the current value of a future sum of money or cash flow given a specified rate of return.

§Arguments

  • rate - The interest rate per period
  • nper - The number of compounding periods
  • pmt - The payment amount per period (negative for cash outflows)
  • fv (optional) - The future value
  • due (optional) - The timing of the payment (false = end of period, true = beginning of period), default is false (ordinary annuity)

At least one of pmt or fv should be non-zero.

§Returns

The present value (PV)

§Example

10 Year bond with 3% YTM, $1000 future value, and 5% coupon rate (paid annually)

  • 5% interest rate
  • 10 compounding periods
  • $50 payment per period (5% of $1000)
use rust_finprim::tvm::pv;
use rust_decimal_macros::*;

let rate = dec!(0.05); let nper = dec!(10); let pmt = dec!(-50); let fv = dec!(1000);
pv(rate, nper, pmt, Some(fv), None);