FloatLeg#
- class rateslib.legs.FloatLeg(*args, float_spread=NoInput.blank, fixings=NoInput.blank, fixing_method=NoInput.blank, method_param=NoInput.blank, spread_compound_method=NoInput.blank, **kwargs)#
Bases:
BaseLeg
,FloatLegMixin
Create a floating leg composed of
FloatPeriod
s.- Parameters:
args (tuple) – Required positional args to
BaseLeg
.float_spread (float, optional) – The spread applied to determine cashflows in bps (i.e. 100 = 1%). 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, Series, 2-tuple, 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
. If a 2-tuple of value and Series, the first scalar value is applied to the first period and latter periods handled as with Series.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.kwargs (dict) – Required keyword arguments to
BaseLeg
.
Notes
The NPV of a FloatLeg is the sum of the period NPVs.
\[P = \underbrace{- \sum_{i=1}^n {N_i r_i(r_j, z) d_i v_i(m_i)}}_{\text{regular flows}} \underbrace{+ N_1 v(m_0) - \sum_{i=1}^{n-1}v(m_i)(N_{i}-N_{i+1}) - N_n v(m_n)}_{\text{exchange flows}}\]The analytic delta is the sum of the period analytic deltas.
\[A = -\frac{\partial P}{\partial z} = \sum_{i=1}^n {\frac{\partial r_i}{\partial z} N_i d_i v_i(m_i)}\]Warning
When floating rates are determined from historical fixings the forecast
Curve
calendar
will be used to determine fixing dates. If this calendar does not align with theLeg
calendar
then spurious results or errors may be generated.Including the curve calendar within a Leg multi-holiday calendar is acceptable, i.e. a Leg calendar of “nyc,ldn,tgt” and a curve calendar of “ldn” is valid. A Leg calendar of just “nyc,tgt” may give errors.
Examples
Set the first fixing on an historic IBOR leg.
In [1]: float_leg = FloatLeg( ...: effective=dt(2021, 12, 1), ...: termination="9M", ...: frequency="Q", ...: fixing_method="ibor", ...: fixings=2.00, ...: ) ...: In [2]: float_leg.cashflows(curve) Out[2]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy 0 FloatPeriod Regular USD 2021-12-01 2022-03-01 2022-03-03 ACT360 0.25 1000000.00 1.00 None 2.00 0.00 -5000.00 -4983.15 1.00 -4983.15 1 FloatPeriod Regular USD 2022-03-01 2022-06-01 2022-06-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5062.13 1.00 -5062.13 2 FloatPeriod Regular USD 2022-06-01 2022-09-01 2022-09-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5036.41 1.00 -5036.41
Set multiple fixings on an historic IBOR leg.
In [3]: float_leg = FloatLeg( ...: effective=dt(2021, 9, 1), ...: termination="12M", ...: frequency="Q", ...: fixing_method="ibor", ...: fixings=[1.00, 2.00], ...: ) ...: In [4]: float_leg.cashflows(curve) Out[4]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy 0 FloatPeriod Regular USD 2021-09-01 2021-12-01 2021-12-03 ACT360 0.25 1000000.00 0.00 None 1.00 0.00 -2527.78 0.00 1.00 0.00 1 FloatPeriod Regular USD 2021-12-01 2022-03-01 2022-03-03 ACT360 0.25 1000000.00 1.00 None 2.00 0.00 -5000.00 -4983.15 1.00 -4983.15 2 FloatPeriod Regular USD 2022-03-01 2022-06-01 2022-06-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5062.13 1.00 -5062.13 3 FloatPeriod Regular USD 2022-06-01 2022-09-01 2022-09-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5036.41 1.00 -5036.41
It is not best practice to supply fixings as a list of values. It is better to supply a Series indexed by IBOR publication date (in this case lagged by zero days).
In [5]: float_leg = FloatLeg( ...: effective=dt(2021, 9, 1), ...: termination="12M", ...: frequency="Q", ...: fixing_method="ibor", ...: method_param=0, ...: fixings=Series([1.00, 2.00], index=[dt(2021, 9, 1), dt(2021, 12, 1)]) ...: ) ...: In [6]: float_leg.cashflows(curve) Out[6]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy 0 FloatPeriod Regular USD 2021-09-01 2021-12-01 2021-12-03 ACT360 0.25 1000000.00 0.00 None 1.00 0.00 -2527.78 0.00 1.00 0.00 1 FloatPeriod Regular USD 2021-12-01 2022-03-01 2022-03-03 ACT360 0.25 1000000.00 1.00 None 2.00 0.00 -5000.00 -4983.15 1.00 -4983.15 2 FloatPeriod Regular USD 2022-03-01 2022-06-01 2022-06-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5062.13 1.00 -5062.13 3 FloatPeriod Regular USD 2022-06-01 2022-09-01 2022-09-03 ACT360 0.26 1000000.00 0.99 None 2.00 0.00 -5105.18 -5036.41 1.00 -5036.41
Set the initial RFR fixings in the first period of an RFR leg (notice the sublist and the implied -10% year end turn spread).
In [7]: swestr_curve = Curve({dt(2023, 1, 2): 1.0, dt(2023, 7, 2): 0.99}, calendar="stk") In [8]: float_leg = FloatLeg( ...: effective=dt(2022, 12, 28), ...: termination="2M", ...: frequency="M", ...: fixings=[[1.19, 1.19, -8.81]], ...: currency="SEK", ...: calendar="stk" ...: ) ...: In [9]: float_leg.cashflows(swestr_curve) Out[9]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy 0 FloatPeriod Regular SEK 2022-12-28 2023-01-30 2023-02-01 ACT360 0.09 1000000.00 1.00 None 0.97 0.00 -886.81 -885.34 1.00 -885.34 1 FloatPeriod Regular SEK 2023-01-30 2023-02-28 2023-03-02 ACT360 0.08 1000000.00 1.00 None 2.00 0.00 -1611.57 -1606.30 1.00 -1606.30 In [10]: float_leg.fixings_table(swestr_curve)[dt(2022,12,28):dt(2023,1,4)] Out[10]: notional dcf rates obs_dates 2022-12-28 0.00 0.00 1.19 2022-12-29 0.00 0.00 1.19 2022-12-30 0.00 0.01 -8.81 2023-01-02 -999220.92 0.00 2.00 2023-01-03 -999276.41 0.00 2.00 2023-01-04 -999331.90 0.00 2.00
Again, this is poor practice. It is best practice to supply a Series of RFR rates by reference value date.
In [11]: float_leg = FloatLeg( ....: effective=dt(2022, 12, 28), ....: termination="2M", ....: frequency="M", ....: fixings=Series([1.19, 1.19, -8.81], index=[dt(2022, 12, 28), dt(2022, 12, 29), dt(2022, 12, 30)]), ....: currency="SEK", ....: calendar="stk", ....: ) ....: In [12]: float_leg.cashflows(swestr_curve) Out[12]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Spread Cashflow NPV FX Rate NPV Ccy 0 FloatPeriod Regular SEK 2022-12-28 2023-01-30 2023-02-01 ACT360 0.09 1000000.00 1.00 None 0.97 0.00 -886.81 -885.34 1.00 -885.34 1 FloatPeriod Regular SEK 2023-01-30 2023-02-28 2023-03-02 ACT360 0.08 1000000.00 1.00 None 2.00 0.00 -1611.57 -1606.30 1.00 -1606.30 In [13]: float_leg.fixings_table(swestr_curve)[dt(2022,12,28):dt(2023,1,4)] Out[13]: notional dcf rates obs_dates 2022-12-28 0.00 0.00 1.19 2022-12-29 0.00 0.00 1.19 2022-12-30 0.00 0.01 -8.81 2023-01-02 -999220.92 0.00 2.00 2023-01-03 -999276.41 0.00 2.00 2023-01-04 -999331.90 0.00 2.00
Methods Summary
analytic_delta
(*args, **kwargs)Return the analytic delta of the FloatLeg via summing all periods.
cashflows
(*args, **kwargs)Return the properties of the FloatLeg used in calculating cashflows.
fixings_table
(*args, **kwargs)Return a DataFrame of fixing exposures on a
FloatLeg
.npv
(*args, **kwargs)Return the NPV of the FloatLeg via summing all periods.
Methods Documentation
- analytic_delta(*args, **kwargs)#
Return the analytic delta of the FloatLeg via summing all periods.
For arguments see
BasePeriod.analytic_delta()
.
- cashflows(*args, **kwargs)#
Return the properties of the FloatLeg used in calculating cashflows.
For arguments see
BasePeriod.cashflows()
.
- fixings_table(*args, **kwargs)#
Return a DataFrame of fixing exposures on a
FloatLeg
.For arguments see
FloatPeriod.fixings_table()
.
- npv(*args, **kwargs)#
Return the NPV of the FloatLeg via summing all periods.
For arguments see
BasePeriod.npv()
.