The purpose of this primer is to show how to create and work with interest rate swaps.
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 sigfrom sigtech.framework.instruments.ir_otc import IRSwapMarketimport datetime as dtmimport pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as pltsns.set(rc={'figure.figsize':(18,6)})env = sig.init()
The instantiation of an interest rate swap is shown below, where a standard 6M EURIBOR IRS 30/360 semi annual a receiver (receives fixed, pays floating) is created.
Below a 3M ERIBOR receiver (receives fixed, pays floating) - to include the notional amount use swap_details method) is created.
irs_3m = sig.InterestRateSwap( currency='EUR', tenor='10Y', trade_date=dtm.date(2017, 1, 4), start_date=dtm.date(2017, 6, 20), value_post_start=True, overrides={'forecast_curve':'EUR.F3M CURVE', 'fixes_index':'EUR003M INDEX', # what fixing to get'float_frequency': '3M', # This field determines the index tenor } )
irs_3m.floating_frequency
'3M'
Curves
The swaps make use of historic forecasting and discounting curves.
Discounting methodology - LIBOR replacement
Discounting is performed from standard curves such us USD.D, EUR.D and GBP.D. For USD discounting, the curve is constructed from EFFR (Effective Fed Fund Rate) up to 18th Oct 2020. After this date it is being replaced by SOFR (Secured Overnight Financing Rate) from 19th Oct 2020. Similarly, for EUR.D curve, EONIA (Euro OverNight Index Average) is the reference rate up to 26th Jul 2020 and then replaced by ESTR (Euro short-term rate) from 27th Jul 2020.
discounting_curve = sig.obj.get(IRSwapMarket.discounting_curve_name('USD'))dt = pd.Timestamp(2019, 12, 30)discounting_curve_history = discounting_curve.history()discounting_curve_data = discounting_curve_history.loc[dt]discounting_curve_df = pd.Series(discounting_curve_data)discounting_curve_data.plot( title=discounting_curve.name +' Discount Factors as of '+str(dt));
Below the net present value as a time series is generated:
npv = pd.concat({'6M Euribor Swap NPV': irs_std.history('LastPrice'),'3M Euribor Swap NPV': irs_3m.history('LastPrice')}, axis=1)npv.iloc[0]# value per unit