Book Image

Mastering Python for Finance

Book Image

Mastering Python for Finance

Overview of this book

Table of Contents (17 chapters)
Mastering Python for Finance
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Valuing a zero-coupon bond


A zero-coupon bond is a bond that does not pay any periodic interest except on maturity, where the principal or face value is repaid. Zero-coupon bonds are also called pure discount bonds.

A zero-coupon bond can be valued as follows:

Here, is the annually compounded yield or rate of the bond, and is the time remaining to the maturity of the bond.

Let's take a look at an example of a 5-year zero-coupon bond with a face value of $100. The yield is 5 percent, compounded annually. The price can be calculated as follows:

A simple Python zero-coupon bond calculator can be used to illustrate this example:

def zero_coupon_bond(par, y, t):
    """
    Price a zero coupon bond.
    
    Par - face value of the bond.
    y - annual yield or rate of the bond.
    t - time to maturity in years.
    """
    return par/(1+y)**t

Using the preceding example, we get the following result:

>>> print zero_coupon_bond(100, 0.05, 5)
78.3526166468

In the preceding example, we assumed...