The price of a bond at the time we purchase it is the present value of all the future streams of payments.
For example, there is a bond with a $2000 face value which will pay a coupon rate of 8% once per year. If the bond will be matured in 5 years and the annual compound interest rate is 6% for all loan terms, what is the price of the bond?
The calculation process of the bond price is as follows:
From the illustration of the bond price calculation above, we can see the price is a summation of the discounted cash flow over the bond period of time. The higher the interest rate the lower the bond price. This means the bond price is correlated negatively with the interest rate.
We can easily use the Python Numpy-Financial pv function to simplify the entire calculation process into several lines of scripts.
Line 1–2: Import required libraries.
Line 4–7: Define and assign the values to all the required parameters.
Line 9: Apply the Python Financial-Numpy pv function to calculate the bond price.
(Note: The original resulting value will be negative and that’s the reason we multiply the value with -1 to turn it to a positive value.)
Line 10: Display the result.
As shown in the script above, all the tedious calculations are encapsulated by the Numpy-Financial pv function. All we need to do is to apply the appropriate parameters to the function.
Continue reading: https://towardsdatascience.com/how-to-perform-bond-valuation-with-python-bbd0cf77417?source=rss—-7f60cf5620c9—4