SBS#
- class rateslib.instruments.SBS(*args, float_spread=NoInput.blank, spread_compound_method=NoInput.blank, fixings=NoInput.blank, fixing_method=NoInput.blank, method_param=NoInput.blank, leg2_float_spread=NoInput.blank, leg2_spread_compound_method=NoInput.blank, leg2_fixings=NoInput.blank, leg2_fixing_method=NoInput.blank, leg2_method_param=NoInput.blank, **kwargs)#
Bases:
BaseDerivative
Create a single currency basis swap composing two
FloatLeg
s.- Parameters:
args (tuple) – Required positional args to
BaseDerivative
.float_spread (float, optional) – The spread applied to the
FloatLeg
. Can be set to None and designated later, perhaps after a mid-market spread for all periods has been calculated.spread_compound_method (str, optional) – The method to use for adding a floating spread to compounded rates. Available options are {“none_simple”, “isda_compounding”, “isda_flat_compounding”}.
fixings (float, list, or Series optional) – If a float scalar, will be applied as the determined fixing for the first period. If a list of n fixings will be used as the fixings for the first n periods. If any sublist of length m is given, is used as the first m RFR fixings for that
FloatPeriod
. If a datetime indexedSeries
will use the fixings that are available in that object, and derive the rest from thecurve
.fixing_method (str, optional) – The method by which floating rates are determined, set by default. See notes.
method_param (int, optional) – A parameter that is used for the various
fixing_method
s. See notes.leg2_float_spread (float or None) – The floating spread applied in a simple way (after daily compounding) to the second
FloatLeg
. If None will be set to zero. float_spread : float, optional The spread applied to theFloatLeg
. Can be set to None and designated later, perhaps after a mid-market spread for all periods has been calculated.leg2_spread_compound_method (str, optional) – The method to use for adding a floating spread to compounded rates. Available options are {“none_simple”, “isda_compounding”, “isda_flat_compounding”}.
leg2_fixings (float, list, or Series optional) – If a float scalar, will be applied as the determined fixing for the first period. If a list of n fixings will be used as the fixings for the first n periods. If any sublist of length m is given, is used as the first m RFR fixings for that
FloatPeriod
. If a datetime indexedSeries
will use the fixings that are available in that object, and derive the rest from thecurve
.leg2_fixing_method (str, optional) – The method by which floating rates are determined, set by default. See notes.
leg2_method_param (int, optional) – A parameter that is used for the various
fixing_method
s. See notes.kwargs (dict) – Required keyword arguments to
BaseDerivative
.
Examples
Construct curves to price the example.
In [1]: eur3m = Curve( ...: nodes={ ...: dt(2022, 1, 1): 1.0, ...: dt(2023, 1, 1): 0.965, ...: dt(2024, 1, 1): 0.94 ...: }, ...: id="eur3m", ...: ) ...: In [2]: eur6m = Curve( ...: nodes={ ...: dt(2022, 1, 1): 1.0, ...: dt(2023, 1, 1): 0.962, ...: dt(2024, 1, 1): 0.936 ...: }, ...: id="eur6m", ...: ) ...:
Create the SBS, and demonstrate the
rate()
,npv()
,analytic_delta()
, andspread()
.In [3]: sbs = SBS( ...: effective=dt(2022, 1, 1), ...: termination="18M", ...: frequency="Q", ...: leg2_frequency="S", ...: calendar="tgt", ...: currency="eur", ...: fixing_method="ibor", ...: method_param=2, ...: convention="Act360", ...: leg2_float_spread=-22.9, ...: notional=100e6, ...: curves=["eur3m", "eur3m", "eur6m", "eur3m"], ...: ) ...: In [4]: sbs.rate(curves=[eur3m, eur3m, eur6m, eur3m]) Out[4]: 2.0110843167657118 In [5]: sbs.npv(curves=[eur3m, eur3m, eur6m, eur3m]) Out[5]: 29592.78143321164 In [6]: sbs.analytic_delta(curve=eur6m, disc_curve=eur3m, leg=2) Out[6]: -14655.336027072415 In [7]: sbs.spread(curves=[eur3m, eur3m, eur6m, eur3m], leg=2) Out[7]: -24.919249601547563
A DataFrame of
cashflows()
.In [8]: sbs.cashflows(curves=[eur3m, eur3m, eur6m, eur3m]) Out[8]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy leg1 0 FloatPeriod Regular EUR 2022-01-03 2022-04-01 2022-04-05 Act360 0.24 100000000.00 0.99 None 3.53 0.00 -862740.56 -854860.93 1.00 -854860.93 1 FloatPeriod Regular EUR 2022-04-01 2022-07-01 2022-07-05 Act360 0.25 100000000.00 0.98 None 3.53 0.00 -892195.77 -876229.44 1.00 -876229.44 2 FloatPeriod Regular EUR 2022-07-01 2022-10-03 2022-10-05 Act360 0.26 100000000.00 0.97 None 3.53 0.00 -921653.87 -897068.41 1.00 -897068.41 3 FloatPeriod Regular EUR 2022-10-03 2023-01-02 2023-01-04 Act360 0.25 100000000.00 0.96 None 3.51 0.00 -887110.37 -855876.84 1.00 -855876.84 4 FloatPeriod Regular EUR 2023-01-02 2023-04-03 2023-04-05 Act360 0.25 100000000.00 0.96 None 2.60 0.00 -656530.12 -629283.32 1.00 -629283.32 5 FloatPeriod Regular EUR 2023-04-03 2023-07-03 2023-07-05 Act360 0.25 100000000.00 0.95 None 2.60 0.00 -656553.75 -625201.19 1.00 -625201.19 leg2 0 FloatPeriod Regular EUR 2022-01-03 2022-07-01 2022-07-05 Act360 0.50 -100000000.00 0.98 None 3.63 -22.90 1804191.59 1771904.59 1.00 1771904.59 1 FloatPeriod Regular EUR 2022-07-01 2023-01-02 2023-01-04 Act360 0.51 -100000000.00 0.96 None 3.62 -22.90 1862131.71 1796569.47 1.00 1796569.47 2 FloatPeriod Regular EUR 2023-01-02 2023-07-03 2023-07-05 Act360 0.51 -100000000.00 0.95 None 2.49 -22.90 1259798.30 1199638.85 1.00 1199638.85
For accurate sensitivity calculations;
delta()
andgamma()
, construct a curve model.In [9]: irs_kws = dict( ...: effective=dt(2022, 1, 1), ...: frequency="A", ...: leg2_frequency="Q", ...: convention="30E360", ...: leg2_convention="Act360", ...: leg2_fixing_method="ibor", ...: leg2_method_param=2, ...: calendar="tgt", ...: currency="eur", ...: curves=["eur3m", "eur3m"], ...: ) ...: In [10]: sbs_kws = dict( ....: effective=dt(2022, 1, 1), ....: frequency="Q", ....: leg2_frequency="S", ....: convention="Act360", ....: fixing_method="ibor", ....: method_param=2, ....: leg2_convention="Act360", ....: calendar="tgt", ....: currency="eur", ....: curves=["eur3m", "eur3m", "eur6m", "eur3m"] ....: ) ....: In [11]: instruments = [ ....: IRS(termination="1Y", **irs_kws), ....: IRS(termination="2Y", **irs_kws), ....: SBS(termination="1Y", **sbs_kws), ....: SBS(termination="2Y", **sbs_kws), ....: ] ....: In [12]: solver = Solver( ....: curves=[eur3m, eur6m], ....: instruments=instruments, ....: s=[1.55, 1.6, 5.5, 6.5], ....: instrument_labels=["1Y", "2Y", "1Y 3s6s", "2Y 3s6s"], ....: id="eur", ....: ) ....: SUCCESS: `func_tol` reached after 4 iterations (levenberg_marquardt), `f_val`: 1.5102207124021666e-13, `time`: 0.0254s In [13]: sbs.delta(solver=solver) Out[13]: local_ccy eur display_ccy eur type solver label instruments eur 1Y 16.70 2Y 9.31 1Y 3s6s 4999.60 2Y 3s6s 9960.31 In [14]: sbs.gamma(solver=solver) Out[14]: type instruments solver eur label 1Y 2Y 1Y 3s6s 2Y 3s6s local_ccy display_ccy type solver label eur eur instruments eur 1Y -0.00 -0.00 -0.19 -0.74 2Y -0.00 0.00 -0.25 -0.12 1Y 3s6s -0.19 -0.25 -0.00 0.00 2Y 3s6s -0.74 -0.12 0.00 -0.00
Attributes Summary
If set will also set the
fixed_rate
of the contained leg1.If set will also set the
float_spread
of contained leg1.If set will also set the
index_base
of the contained leg1.If set will also set the
fixed_rate
of the contained leg2.If set will also set the
float_spread
of contained leg2.If set will also set the
index_base
of the contained leg1.Methods Summary
analytic_delta
(*args, **kwargs)Return the analytic delta of a leg of the derivative object.
cashflows
([curves, solver, fx, base])Return the properties of all legs used in calculating cashflows.
cashflows_table
([curves, solver, fx, base])delta
(*args, **kwargs)Calculate the delta of the Instrument.
gamma
(*args, **kwargs)Calculate the gamma of the Instrument.
npv
([curves, solver, fx, base, local])Return the NPV of the derivative object by summing legs.
rate
([curves, solver, fx, base, leg])Return the mid-market float spread on the specified leg of the SBS.
spread
(*args, **kwargs)Return the mid-market float spread on the specified leg of the SBS.
Attributes Documentation
- fixed_rate#
If set will also set the
fixed_rate
of the contained leg1.Note
fixed_rate
,float_spread
,leg2_fixed_rate
andleg2_float_spread
are attributes only applicable to certainInstruments
. AttributeErrors are raised if calling or setting these is invalid.- Type:
float or None
- float_spread#
If set will also set the
float_spread
of contained leg1.- Type:
float or None
- index_base#
If set will also set the
index_base
of the contained leg1.Note
index_base
andleg2_index_base
are attributes only applicable to certainInstruments
. AttributeErrors are raised if calling or setting these is invalid.- Type:
float or None
- leg2_fixed_rate#
If set will also set the
fixed_rate
of the contained leg2.- Type:
float or None
- leg2_float_spread#
If set will also set the
float_spread
of contained leg2.- Type:
float or None
- leg2_index_base#
If set will also set the
index_base
of the contained leg1.Note
index_base
andleg2_index_base
are attributes only applicable to certainInstruments
. AttributeErrors are raised if calling or setting these is invalid.- Type:
float or None
Methods Documentation
- analytic_delta(*args, **kwargs)#
Return the analytic delta of a leg of the derivative object.
- cashflows(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#
Return the properties of all legs used in calculating cashflows.
- cashflows_table(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#
- delta(*args, **kwargs)#
Calculate the delta of the Instrument.
For arguments see
Sensitivities.delta()
.
- gamma(*args, **kwargs)#
Calculate the gamma of the Instrument.
For arguments see
Sensitivities.gamma()
.
- npv(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False)#
Return the NPV of the derivative object by summing legs.
See
BaseDerivative.npv()
.
- rate(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, leg=1)#
Return the mid-market float spread on the specified leg of the SBS.