Search…
v8 Framework
Learning resources
Get started
API reference
Example notebooks
Framework source code
Asset classes
Equities
FX
Commodities
Futures
Volatility
Fixed income
Bonds
Swaps
Asset swaps
Rolling bond strategy
Rolling swap strategy
Tutorial: duration weighted strategy
Essentials
Platform concepts
Anatomy of a strategy
Instruments
Strategy building blocks
Performance analytics
JupyterLab
Visual Studio Code
Environment setup
Calendars & timezones
Pandas introduction
Default strategies
Quick tips
Strategy
Technical Indicators
User interface
Workspaces
Git
Python packages
Custom Strategies
Custom strategies
Timeline
Time iteration
Base class
Built-in methods
Strategy extension
INTRADAY
Intraday strategies
Querying intraday data
DATA
Custom data sources
Data Extraction API
Data Ingestion API
Platform tools
CLS
Data validation
TRADE IMPLEMENTATION
Position rounding
Trade sizing
Transaction cost
Portfolio Construction & Risk Management
Optimisation
Simulations & scenarios
Beta hedging
Platform
Strategy deployment
Caching service
Release notes
Framework v8
Data
Powered By
GitBook
Rolling bond strategy
Primer on the RollingBondStrategy class.
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
Output
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
);
Python
Output
on_the_run_10y_st
.
roll_schedule
.
tail
()
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
Output
dict_otr
[
'ES_5Y'
].
head
()
API Documentation
To read further on the
RollingBondStrategy
class, please see the
API documentation
.
Previous
Asset swaps
Next
Rolling swap strategy
Last modified
1mo ago
Export as PDF
Copy link
Outline
Introduction
Environment
Creating RollingBondStrategy objects
On-the-run (OTR) schedules
API Documentation