Bond Valuation and Analysis in Python
Joshua Mayhew
Options Trader
$FV = PV \times (1 + r)^n$
$PV = \frac{FV}{(1 + r)^n}$
A higher interest rate or longer time period increases the FV
So a higher interest rate or longer time period must decrease the PV
import numpy_financial as npf
?npf.pv
Signature: npf.pv(rate, nper, pmt, fv=0) Docstring: Compute the present value.
Given: * a future value, `fv`
* an interest `rate` compounded once per period, of which there are
* `nper` total
* a (fixed) payment, `pmt`
Return: the value now
import numpy_financial as npf
npf.pv(rate=0.05, nper=10, pmt=0, fv=10000)
-6139.13
-npf.pv(rate=0.05, nper=10, pmt=0, fv=10000)
6139.13
pv = 10000 / (1 + 0.05) ** 10
print(pv)
6139.13
Let's look at an example of a zero coupon bond that:
What is the price of this bond?
import numpy_financial as npf
-npf.pv(rate=0.035, nper=3, pmt=0, fv=100)
90.19
pv = 100 / (1 + 0.035) ** 3
print(pv)
90.19
Bond Valuation and Analysis in Python