FixedLeg#
- class rateslib.legs.FixedLeg(*args, fixed_rate=NoInput.blank, **kwargs)#
Bases:
BaseLeg
,FixedLegMixin
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 Acc Start Acc End Payment Convention DCF Notional DF Rate Spread Cashflow NPV FX Rate NPV Ccy Collateral 0 Cashflow Exchange USD NaT NaT 2022-01-01 None NaN -1000000.00 1.00 NaN None 1000000.00 1000000.00 1.00 1000000.00 None 1 FixedPeriod Regular USD 2022-01-01 2022-04-01 2022-04-03 ACT360 0.25 1000000.00 0.99 2.00 None -5000.00 -4974.60 1.00 -4974.60 None 2 Cashflow Amortization USD NaT NaT 2022-04-01 None NaN 200000.00 1.00 NaN None -200000.00 -199006.18 1.00 -199006.18 None 3 FixedPeriod Regular USD 2022-04-01 2022-07-01 2022-07-03 ACT360 0.25 800000.00 0.99 2.00 None -4044.44 -4003.68 1.00 -4003.68 None 4 Cashflow Amortization USD NaT NaT 2022-07-01 None NaN 200000.00 0.99 NaN None -200000.00 -198006.34 1.00 -198006.34 None 5 FixedPeriod Regular USD 2022-07-01 2022-10-01 2022-10-03 ACT360 0.26 600000.00 0.98 2.00 None -3066.67 -3020.34 1.00 -3020.34 None 6 Cashflow Exchange USD NaT NaT 2022-10-01 None NaN 600000.00 0.99 NaN None -600000.00 -591001.84 1.00 -591001.84 None In [4]: fixed_leg_exch.npv(curve) Out[4]: -12.99118747760076
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()
.