CreditProtectionLeg#
- class rateslib.legs.CreditProtectionLeg(*args, recovery_rate=NoInput.blank, **kwargs)#
Bases:
BaseLeg
Create a credit protection leg composed of
CreditProtectionPeriod
s.- Parameters:
Notes
The NPV of a credit protection leg is the sum of the period NPVs.
\[P = \sum_{i=1}^n P_i\]The analytic delta is the sum of the period analytic deltas.
\[A = -\frac{\partial P}{\partial S} = \sum_{i=1}^n -\frac{\partial P_i}{\partial S}\]Examples
In [1]: disc_curve = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.98}) In [2]: hazard_curve = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.995}) In [3]: protection_leg = CreditProtectionLeg( ...: schedule=Schedule(dt(2022, 1, 1), "9M", "Z"), ...: notional=1000000, ...: ) ...: In [4]: protection_leg.cashflows(hazard_curve, disc_curve) Out[4]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Recovery Survival Cashflow NPV FX Rate NPV Ccy 0 CreditProtectionPeriod Stub USD 2022-01-01 2022-10-01 2022-10-03 Act360 0.758333 1000000.0 0.984894 None 0.4 0.996258 -600000.0 -2228.384898 1.0 -2228.384898 In [5]: protection_leg.npv(hazard_curve, disc_curve) Out[5]: -2228.3848975139967
Methods Summary
analytic_delta
(*args, **kwargs)Return the analytic delta of the CreditProtectionLeg via summing all periods.
analytic_rec_risk
(*args, **kwargs)Return the analytic recovery risk of the CreditProtectionLeg via summing all periods.
cashflows
(*args, **kwargs)Return the properties of the CreditProtectionLeg used in calculating cashflows.
npv
(*args, **kwargs)Return the NPV of the CreditProtectionLeg via summing all periods.
Methods Documentation
- analytic_delta(*args, **kwargs)#
Return the analytic delta of the CreditProtectionLeg via summing all periods.
For arguments see
BasePeriod.analytic_delta()
.
- analytic_rec_risk(*args, **kwargs)#
Return the analytic recovery risk of the CreditProtectionLeg via summing all periods.
For arguments see
BasePeriod.analytic_delta()
.
- cashflows(*args, **kwargs)#
Return the properties of the CreditProtectionLeg used in calculating cashflows.
For arguments see
BasePeriod.cashflows()
.
- npv(*args, **kwargs)#
Return the NPV of the CreditProtectionLeg via summing all periods.
For arguments see
BasePeriod.npv()
.