FixedLeg#

class rateslib.legs.FixedLeg(*args, fixed_rate=NoInput.blank, **kwargs)#

Bases: _FixedLegMixin, BaseLeg

Create a fixed leg composed of FixedPeriod s.

Parameters:
  • args (tuple) – Required positional args to BaseLeg.

  • fixed_rate (float, optional) – The rate applied to determine cashflows in % (i.e 5.0 = 5%). Can be left unset and designated later, perhaps after a mid-market rate for all periods has been calculated.

  • kwargs (dict) – Required keyword arguments to BaseLeg.

Notes

The NPV of a fixed leg is the sum of the period NPVs.

\[P = \underbrace{- R \sum_{i=1}^n {N_i 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 R} = \sum_{i=1}^n {N_i d_i v_i(m_i)}\]

Examples

In [1]: curve = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.98})

In [2]: fixed_leg_exch = FixedLeg(
   ...:     dt(2022, 1, 1), "9M", "Q",
   ...:     fixed_rate=2.0,
   ...:     notional=1000000,
   ...:     amortization=200000,
   ...:     initial_exchange=True,
   ...:     final_exchange=True,
   ...: )
   ...: 

In [3]: fixed_leg_exch.cashflows(curve)
Out[3]: 
          Type        Period  Ccy    Payment   Notional        DF  Rate        Cashflow             NPV  FX Rate         NPV Ccy Collateral  Acc Start    Acc End Convention       DCF  Spread
0     Cashflow      Exchange  USD 2022-01-01 -1000000.0  1.000000   NaN  1000000.000000  1000000.000000      1.0  1000000.000000       None        NaT        NaT        NaN       NaN     NaN
1  FixedPeriod       Regular  USD 2022-04-03  1000000.0  0.994921   2.0    -5000.000000    -4974.603770      1.0    -4974.603770       None 2022-01-01 2022-04-01     ACT360  0.250000     NaN
2     Cashflow  Amortization  USD 2022-04-01   200000.0  0.995031   NaN  -200000.000000  -199006.179513      1.0  -199006.179513       None        NaT        NaT        NaN       NaN     NaN
3  FixedPeriod       Regular  USD 2022-07-03   800000.0  0.989922   2.0    -4044.444444    -4003.684927      1.0    -4003.684927       None 2022-04-01 2022-07-01     ACT360  0.252778     NaN
4     Cashflow  Amortization  USD 2022-07-01   200000.0  0.990032   NaN  -200000.000000  -198006.337491      1.0  -198006.337491       None        NaT        NaT        NaN       NaN     NaN
5  FixedPeriod       Regular  USD 2022-10-03   600000.0  0.984894   2.0    -3066.666667    -3020.341721      1.0    -3020.341721       None 2022-07-01 2022-10-01     ACT360  0.255556     NaN
6     Cashflow      Exchange  USD 2022-10-01   600000.0  0.985003   NaN  -600000.000000  -591001.843766      1.0  -591001.843766       None        NaT        NaT        NaN       NaN     NaN

In [4]: fixed_leg_exch.npv(curve)
Out[4]: -12.991187477706262

Methods Summary

analytic_delta(*args, **kwargs)

Return the analytic delta of the FixedLeg via summing all periods.

cashflows(*args, **kwargs)

Return the properties of the FixedLeg used in calculating cashflows.

npv(*args, **kwargs)

Return the NPV of the FixedLeg via summing all periods.

Methods Documentation

analytic_delta(*args, **kwargs)#

Return the analytic delta of the FixedLeg via summing all periods.

For arguments see BasePeriod.analytic_delta().

cashflows(*args, **kwargs)#

Return the properties of the FixedLeg used in calculating cashflows.

For arguments see BasePeriod.cashflows().

npv(*args, **kwargs)#

Return the NPV of the FixedLeg via summing all periods.

For arguments see BasePeriod.npv().