More financial functions

Bond Valuation and Analysis in Python

Joshua Mayhew

Options Trader

The nper() function

  • Tells you number of periods required to grow PV to FV
import numpy_financial as npf
?npf.nper
Signature: npf.nper(rate, pmt, pv, fv=0)

Compute the number of periodic payments.

Parameters rate : Rate of interest (per period)
pmt : Payment
pv : Present value
fv : (optional) Future value
Bond Valuation and Analysis in Python

The nper() function

  • How long to save USD 7,000 investing USD 270 per month at 5% per year compounded monthly?
import numpy_financial as npf
npf.nper(rate=0.05/12, pmt=-270, pv=0, fv=7000)
24.67
Bond Valuation and Analysis in Python

The pmt() function

  • Tells you the payment amount required to grow PV to FV
import numpy_financial as npf
?npf.pmt
Signature: npf.pmt(rate, nper, pv, fv=0)

Compute the payment against loan principal plus interest.

Given: * an interest `rate` compounded once per period, of which there are
* `nper` total
* a present value, `pv` (e.g., an amount borrowed)
* a future value, `fv` (e.g., 0)
Return: the (fixed) periodic payment.
Bond Valuation and Analysis in Python

The pmt() function

  • We have borrowed USD 275,000 at an annual rate of 3.5% compounded monthly
  • What monthly payment to pay off a mortgage in ten years?
import numpy_financial as npf
npf.pmt(rate=0.035/12, nper=10*12, pv=275000, fv=0)
-2719.36
Bond Valuation and Analysis in Python

The rate() function

  • Tells you interest rate required to grow PV to FV
import numpy_financial as npf
?npf.rate
Signature: npf.rate(nper, pmt, pv, fv)

Compute the rate of interest per period.

Parameters nper : Number of compounding periods
pmt : Payment
pv : Present value
fv : Future value
Bond Valuation and Analysis in Python

The rate() function

  • What investment return to retire in 30 years?
  • You save USD 1,500 each month and want to end up with USD 1 million.
  • Assume the investments you make have monthly compounding.
import numpy_financial as npf
12 * npf.rate(nper=30*12, pmt=-1500, pv=0, fv=1000000)
0.0377
Bond Valuation and Analysis in Python

Let's practice!

Bond Valuation and Analysis in Python

Preparing Video For Download...