Rolling bond strategy#

Introduction#

The purpose of this primer is to show how the building block RollingBondStrategy works.

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

import sigtech.framework as sig
from sigtech.framework.schedules.roll_schedules.bond_schedule import otr_series

import datetime as dtm
import pandas as pd
import seaborn as sns

sns.set(rc={'figure.figsize': (18, 6)})
sig.config.init()

Learn more: setting up the environment.

Creating RollingBondStrategy objects #

The RollingBondStrategy continually rolls on-the-run or off-the-run bonds for different tenors and issuers.

Here we define a helper function to generate the rolling bond strategies we will consider.

def get_rb(tenor, run_type):
    return sig.RollingBondStrategy(
        country='US',
        currency='USD',
        run_type=run_type,
        # 'ON_THE_RUN', 'FIRST_OFF_THE_RUN', 'SECOND_OFF_THE_RUN'
        start_date=dtm.date(2017, 1, 5),
        tenor=tenor,  # e.g. '2y', '5Y', '10Y', '30y'
    )
on_the_run_10y_st = get_rb('10Y', 'ON_THE_RUN')
first_off_the_run_10y_st = get_rb('10Y', 'FIRST_OFF_THE_RUN')

Examples of on-the-run and off-the-run rolling strategies is given below, together with one roll schedule.

Python:

on_the_run_10y_st.history().plot(label='on_the_run', legend=True);
first_off_the_run_10y_st.history().plot(label='first_off_the_run', legend=True);

Output:

Python:

on_the_run_10y_st.roll_schedule.tail()

Output:

effective_date
2020-02-19      US 1.5 2030/02/15 GOVT
2020-05-19    US 0.625 2030/05/15 GOVT
2020-08-18    US 0.625 2030/08/15 GOVT
2020-12-02    US 0.875 2030/11/15 GOVT
2021-02-22    US 1.125 2031/02/15 GOVT
Name: bond_name, dtype: object

On-the-run (OTR) schedules #

An alternative way of creating on-the-run RollingBondStrategy strategies, is to use the pre-built OTR schedules which can be access via the otr_series function as per below.

def get_schedules(country, tenor):
    return otr_series(
        group_name=f'{country} GOVT BOND GROUP',
        tenor=tenor,
        start=dtm.date(2005,1,5)
    )

dict_otr = {}
TENORS = ['5Y']
COUNTRIES = ['ES']
for country in COUNTRIES:
    for tenor in TENORS:
        dict_otr[f'{country}_{tenor}'] = get_schedules(country, tenor)

Python:

dict_otr['ES_5Y'].head()

Output:

API Documentation#

For more information on the RollingBondStrategy class, see the API documentation.