Duration Weighted Strategy#

Understand this code: Read our step-by-step explanation of this notebook: guided walkthrough.

Restricted data: You will only have access to the data used in this notebook if your organisation has specifically purchased it. To check your current data access, view Data. If you would like to access more data, please contact sales@sigtech.com.

Changes will not be saved: Edits made to SigTech’s example notebooks like this will only persist for the duration of your session. When you restart the research environment, this notebook will have been restored to its original state, and any changes you have made will have been lost. To make permanent changes, copy and paste the content to a new notebook in one of your workspaces.

Environment#

[ ]:
import sigtech.framework as sig

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

sns.set(rc = {'figure.figsize': (18, 6)})
env = sig.init(env_date=dtm.date(2024, 2, 22))

Define the universe#

[ ]:
start_date = dtm.date(2018, 1, 5)
group = sig.obj.get('US GOVT BOND GROUP')
tenors = ['30Y', '5Y']
[ ]:
def create_otr(group: str, tenor: str, start_date: dtm.date) -> sig.RollingBondStrategy:
    return sig.RollingBondStrategy(
        # Assing the country of the bond group
        country=group.country,

        # The strategy denomination currency
        currency='USD',

        # Which bonds to be used as part of the strategy,
        # could e.g. be 'ON_THE_RUN', 'FIRST_OFF_THE_RUN',
        # 'SECOND_OFF_THE_RUN' etc.
        run_type='ON_THE_RUN',

        # Start date of strategy
        start_date=start_date,

        # Tenor of strategy
        tenor=tenor,

        # Name of strategy
        ticker=f'{tenor} {group.country} OTR'
    )
[ ]:
otr_dict = {
    tenor: create_otr(group, tenor, start_date)
    for tenor in tenors
}

Create the strategy#

[ ]:
dur_dict = {
    tenor: otr_dict[tenor].ann01_series()
    for tenor in tenors
}
[ ]:
df= pd.DataFrame({otr_dict['5Y'].name:-(dur_dict['30Y']/dur_dict['5Y']),otr_dict['30Y'].name:1}).dropna()
df.head()

Construct the portfolio#

[ ]:
signal_obj = sig.signal_library.from_ts(df)
signal_obj
[ ]:
duration_weighted_strat = sig.SignalStrategy(
    # Start date of strategy
    start_date=start_date,

    # Currency in which the strategy is denominated in
    currency='USD',

    # Reference to the signal object
    signal_name=signal_obj.name,

    # On the instruments which have a negative weight,
    # refrain from creating a short version of that
    # instrument
    convert_long_short_weight=False
)

Generate the performance report#

[ ]:
sig.PerformanceReport(duration_weighted_strat.history()).report()