Bonds
Primer on bonds.
Introduction
The purpose of this notebook is to show functionality related to bonds on the platform.
A notebook containing all the code used in this page can be accessed in the research environment: Example notebooks.
Environment
Setting up your environment takes three steps:
Import the relevant internal and external libraries
Configure the environment parameters
Initialise the environment
Learn more: setting up the environment.
Government Bond Instrument
Government bonds are objects that can be retrieved by the object name constructed by the Country code, coupon, maturity date and 'GOVT' key.
Each bond has various data elements accessible through their objects. The available time series for bond instruments are stored in the properties .history_fields
and .extra_fields
and are the following:
For querying the listed time series, the name of the time series can be passed in as the field
parameter in the method .history(field = )
as shown below:
Furthermore, the bond also holds relevant static data as seen below:
Every single bond is part of a bond group, where a bond group contains all bonds issued by an issuer.
As shown above, the bond group also acts as an object, therefore it holds functionality and data on its own. An example of the functionality is to query all bonds in a bond group which is shown below:
All coupons can be retrieved by the method .cashflows()
as shown below:
Z-spread
The z-spread is calculated using the Python QuantLib library. Below is an example of when calculating the z-spread on a given date. For more information on the Python QuantLib library, see the Python QuantLib documentation.
The z-spread can also be retrieved as a time series as shown below:
Asset swap spread
The asset swap spread is also calculated using the Python QuantLib library. The asset swap spread can be retrieved for a given date with the following method:
Convexity
Modified duration
Creating Strategies
To create strategies of forward contract, users can easily make use of the building block RollingBondStrategy
object. For further information on RollingBondStrategy
, see Rolling Bond Strategy.
Last updated