Skip to content

Foundations

Time value of money

Present and future values of sums, annuities and perpetuities, the five-key solve, NPV, IRR, XNPV, XIRR and amortization schedules.

Model id
foundations.time_value, version 2
Domain
Foundations
Evidence
standard
Cost class
light: A short numerical method; a hosted run may take up to 10 seconds.

Formula

PV=FV(1+r)n+PMT 1−(1+g1+r)nr−g (1+r)dPV = \frac{FV}{(1+r)^n} + PMT\,\frac{1 - \left(\frac{1+g}{1+r}\right)^n}{r - g}\,(1+r)^{d}FV=PV(1+r)n+PMT (1+r)n−(1+g)nr−g (1+r)d\begin{aligned} FV &= PV (1+r)^n \\ &\quad + PMT\,\frac{(1+r)^n - (1+g)^n}{r - g}\,(1+r)^{d} \end{aligned}PV∞=PMTr−g (1+r)d,r>gPV_{\infty} = \frac{PMT}{r - g}\,(1+r)^{d}, \quad r > gPV(1+r)n+PMT(1+rd)(1+r)n−1r+FV=0\begin{aligned} & PV (1+r)^n + PMT (1 + r d) \frac{(1+r)^n - 1}{r} \\ & \quad + FV = 0 \end{aligned}NPV=∑t=0TCt(1+r)t,NPV(IRR)=0NPV = \sum_{t=0}^{T} \frac{C_t}{(1+r)^t}, \quad NPV(IRR) = 0XNPV=∑iCi(1+r)(di−d0)/365XNPV = \sum_i \frac{C_i}{(1+r)^{(d_i - d_0)/365}}XNPV(XIRR)=0XNPV(XIRR) = 0PMT=P r1−(1+r)−n,Bk=P an−kanPMT = \frac{P\,r}{1 - (1+r)^{-n}}, \quad B_k = P\,\frac{a_{n-k}}{a_n}

Where

PVPV
Present value present_value
FVFV
Future value future_value
PMTPMT
The payment each period payment
rr
Interest rate per period rate
nn
Number of periods periods
gg
Growth rate of the payment per period growth
dd
1 when each payment falls at the start of its period (an annuity due), 0 at the end due
PV∞PV_{\infty}
Present value of a perpetuity present_value
NPVNPV
Net present value npv
CtC_t
The cash flow at period t; negative when paid out cash_flows
IRRIRR
Internal rate of return: the rate at which the net present value is zero irr
XNPVXNPV
Net present value of dated cash flows xnpv
CiC_i
The i-th dated cash flow cash_flows
did_i
The date of cash flow i; d_0 is the first date dates
XIRRXIRR
Internal rate of return of dated cash flows, per year xirr
PP
Principal of the loan principal
BkB_k
Balance left after payment k balance
ana_n
The annuity factor: the present value of 1 a period for n periods

Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.

Variables

Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.

Inputs

Discount a sum and a stream of payments (present_value): 7 inputs
Inputs of the calculation present_value
NameDescription
CalculationcalculationtextDiscount a sum and a stream of payments
Rateraterate · [-0.99, 1]Discount rate per period
Periodsperiodsperiods · [0, 1200]Number of periods; omitted (null) for a perpetuity
Paymentpaymentmoney · [-1e+12, 1e+12]First payment of the stream (0 for none)
Growthgrowthrate · [-0.99, 1]Growth of each payment over the last, per period
Future valuefuture_valuemoney · [-1e+12, 1e+12]Single sum at the end of the last period (0 for none)
DuedueflagPayments at the start of each period (an annuity due)
Compound a sum and a stream of payments (future_value): 7 inputs
Inputs of the calculation future_value
NameDescription
CalculationcalculationtextCompound a sum and a stream of payments
Rateraterate · [-0.99, 1]Interest rate per period
Periodsperiodsperiods · [0, 1200]Number of periods
Paymentpaymentmoney · [-1e+12, 1e+12]First payment of the stream (0 for none)
Growthgrowthrate · [-0.99, 1]Growth of each payment over the last, per period
Present valuepresent_valuemoney · [-1e+12, 1e+12]Single sum invested now (0 for none)
DuedueflagPayments at the start of each period (an annuity due)
Solve the time-value equation for the omitted term (solve): 7 inputs
Inputs of the calculation solve
NameDescription
CalculationcalculationtextSolve the time-value equation for the omitted term
Periodsperiodsperiods · [0, 1200]Number of periods (N)
Rateraterate · [-0.99, 1]Interest rate per period (I/Y)
Present valuepresent_valuemoney · [-1e+12, 1e+12]Cash flow now (PV); negative when paid out
Paymentpaymentmoney · [-1e+12, 1e+12]Level cash flow each period (PMT); negative when paid out
Future valuefuture_valuemoney · [-1e+12, 1e+12]Cash flow at the end (FV); negative when paid out
DuedueflagPayments at the start of each period
Net present value (npv): 3 inputs
Inputs of the calculation npv
NameDescription
CalculationcalculationtextNet present value
Rateraterate · [-0.99, 1]Discount rate per period
Cash flowscash_flowsmoney (array) · length min 1, max 1201; each [-1e+12, 1e+12]Cash flows at times 0, 1, 2, ... periods; the first is not discounted
Internal rate of return (irr): 2 inputs
Inputs of the calculation irr
NameDescription
CalculationcalculationtextInternal rate of return
Cash flowscash_flowsmoney (array) · length min 1, max 1201; each [-1e+12, 1e+12]Cash flows at times 0, 1, 2, ... periods
Net present value of dated cash flows (xnpv): 4 inputs
Inputs of the calculation xnpv
NameDescription
Cash flowscash_flowsmoney (array) · length min 1, max 1000; each [-1e+12, 1e+12]Cash flows, one per date
Datesdatesdate (array) · length min 1, max 1000The date of each cash flow; the first is the base date
CalculationcalculationtextNet present value of dated cash flows
Rateraterate · [-0.99, 10]Annual discount rate
Internal rate of return of dated cash flows (xirr): 3 inputs
Inputs of the calculation xirr
NameDescription
Cash flowscash_flowsmoney (array) · length min 1, max 1000; each [-1e+12, 1e+12]Cash flows, one per date
Datesdatesdate (array) · length min 1, max 1000The date of each cash flow; the first is the base date
CalculationcalculationtextInternal rate of return of dated cash flows
Level-payment amortization schedule (amortization): 4 inputs
Inputs of the calculation amortization
NameDescription
CalculationcalculationtextLevel-payment amortization schedule
Principalprincipalmoney · (0, 1e+12]Amount borrowed
Rateraterate · [-0.99, 1]Interest rate per period
Periodsperiodscount · [1, 1200]Number of payments

Outputs

Discount a sum and a stream of payments (present_value): 2 outputs
Outputs of the calculation present_value
NameDescription
CalculationcalculationtextDiscount a sum and a stream of payments
Present valuepresent_valuemoney · [-1e+15, 1e+15]Present value of the sum and the payments
Compound a sum and a stream of payments (future_value): 2 outputs
Outputs of the calculation future_value
NameDescription
CalculationcalculationtextCompound a sum and a stream of payments
Future valuefuture_valuemoney · [-1e+15, 1e+15]Future value of the sum and the payments
Solve the time-value equation for the omitted term (solve): 7 outputs
Outputs of the calculation solve
NameDescription
CalculationcalculationtextSolve the time-value equation for the omitted term
Solved forsolved_fortextThe term that was omitted and solved
Periodsperiodsperiods · [0, 1200]Number of periods (N)
Rateraterate · [-0.99, 1]Interest rate per period
Present valuepresent_valuemoney · [-1e+15, 1e+15]Cash flow now (PV)
Paymentpaymentmoney · [-1e+15, 1e+15]Level cash flow each period (PMT)
Future valuefuture_valuemoney · [-1e+15, 1e+15]Cash flow at the end (FV)
Net present value (npv): 2 outputs
Outputs of the calculation npv
NameDescription
CalculationcalculationtextNet present value
NPVnpvmoney · [-1e+15, 1e+15]Net present value at time 0
Internal rate of return (irr): 3 outputs
Outputs of the calculation irr
NameDescription
CalculationcalculationtextInternal rate of return
IRRirrrate · [-0.99, 10]Rate per period at which the NPV is zero; null when undefined
Sign changessign_changescount · [0, 1201]Sign changes in the cash flows
Net present value of dated cash flows (xnpv): 2 outputs
Outputs of the calculation xnpv
NameDescription
CalculationcalculationtextNet present value of dated cash flows
XNPVxnpvmoney · [-1e+15, 1e+15]Net present value at the first date
Internal rate of return of dated cash flows (xirr): 3 outputs
Outputs of the calculation xirr
NameDescription
CalculationcalculationtextInternal rate of return of dated cash flows
XIRRxirrrate · [-0.99, 10]Annual rate at which the XNPV is zero; null when undefined
Sign changessign_changescount · [0, 1000]Sign changes in the cash flows
Level-payment amortization schedule (amortization): 8 outputs
Outputs of the calculation amortization
NameDescription
CalculationcalculationtextLevel-payment amortization schedule
Level paymentlevel_paymentmoney · [0, 2e+12]The level payment each period
Total interesttotal_interestmoney · [-2e+12, 2.4e+15]Interest paid over the loan
Periodperiodcount (array) · length max 1200; each [1, 1200]Payment numbers, 1 to n
Paymentpaymentmoney (array) · length max 1200; each [-1e+15, 1e+15]Payment in each period
Interestinterestmoney (array) · length max 1200; each [-1e+15, 1e+15]Interest part of each payment
Principalprincipalmoney (array) · length max 1200; each [-1e+15, 1e+15]Principal part of each payment
Balancebalancemoney (array) · length max 1200; each [-1e+15, 1e+15]Balance after each payment

Calculator

Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.

Loading the calculator…

Worked example

Twenty years of $500 a month at 8% a year.

Example monthly_annuity. Inputs:

{
  "calculation": "present_value",
  "due": false,
  "future_value": 0,
  "growth": 0,
  "payment": 500,
  "periods": 240,
  "rate": 0.006666666666666667
}

Outputs:

{
  "calculation": "present_value",
  "present_value": 59777.14585118803
}

Assumptions

  • The rate is constant and compounds once per period; payments fall at the end of each period, or at its start when due is true (d = 1).
  • A growing payment grows by the same rate each period, starting from the payment given for the first period.
  • solve follows the cash-flow sign convention: money paid out is negative, and the equation balances to zero.
  • npv and irr place the first cash flow at time 0, undiscounted; xnpv and xirr count years of 365 days from the first date (ACT/365 Fixed).
  • An IRR is the smallest root in its bracket (ADR-0008 decision 11); the scan steps by 0.01, so two roots closer than that can be seen as none.

Limitations

  • A result outside its output's bounds (for example a sum compounded at 100% a period for a thousand periods) raises DomainError.
  • A perpetuity needs a rate above its growth rate and no final sum, or DomainError is raised.
  • solve raises DomainError when no value of the omitted term balances the cash flows (no rate in [-0.99, 1] per period, no non-negative number of periods, or a payment over zero periods).
  • An IRR or XIRR is null with a warning when the cash flows never change sign or no root lies in [-0.99, 10].
  • Taxes, fees, inflation and day-count conventions other than ACT/365 Fixed are out of scope.

Evidence

Status: standard. Textbook consensus, such as bond duration or the CAPM formula.

Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).

Syllabus

The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.

Citations

  1. Kellison, S. G. (2009). The Theory of Interest, 3rd ed. McGraw-Hill/Irwin. https://openlibrary.org/isbn/9780073382449 (Chapters 3-5 (annuities, varying annuities, amortization schedules)). ISBN 9780073382449
  2. Microsoft (n.d.). XNPV function. Microsoft Support. https://support.microsoft.com/en-us/office/xnpv-function-1b42bbf6-370f-4532-a0eb-d67c16b664b7 (Description (the XNPV equation) and Example)
  3. Microsoft (n.d.). XIRR function. Microsoft Support. https://support.microsoft.com/en-us/office/xirr-function-de1242ec-6477-445b-b11b-a303ad9adc9d (Remarks (the XIRR equation) and Example)

Changelog

  • Version 1: First version.
  • Version 2: Recognize IRR roots at inclusive bracket endpoints (#85).

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/foundations.time_value/run
MCP tool
foundations_time_value, or run_model with the model's id; both give the same result. Connect an assistant
Command line
pyeconomics models run foundations.time_value --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "calculation": "present_value",
    "due": False,
    "future_value": 0,
    "growth": 0,
    "payment": 500,
    "periods": 240,
    "rate": 0.006666666666666667,
}
result = pyeconomics.run("foundations.time_value", inputs)
print(result.to_json())
Command line
pyeconomics models run foundations.time_value --inputs - <<'JSON'
{
  "calculation": "present_value",
  "due": false,
  "future_value": 0,
  "growth": 0,
  "payment": 500,
  "periods": 240,
  "rate": 0.006666666666666667
}
JSON