CreditProtectionLeg#
- class rateslib.legs.CreditProtectionLeg(*args, recovery_rate=NoInput.blank, discretization=NoInput.blank, **kwargs)#
Bases:
BaseLegCreate a credit protection leg composed of
CreditProtectionPeriods.- Parameters:
args (tuple) – Required positional args to
BaseLeg.recovery_rate (float, Dual, Dual2, optional) – The assumed recovery rate that defines payment on credit default. Set by
defaults.discretization (int, optional) – The number of days to discretize the numerical integration over possible credit defaults. Set by
defaults.kwargs (dict) – Required keyword arguments to
BaseLeg.
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( ...: dt(2022, 1, 1), "9M", "Z", ...: recovery_rate=0.40, ...: 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 Regular USD 2022-01-01 2022-10-01 2022-10-03 ACT360 0.76 1000000.00 0.98 None 0.40 1.00 -600000.00 -2228.38 1.00 -2228.38 In [5]: protection_leg.npv(hazard_curve, disc_curve) Out[5]: -2228.3848975139967
Attributes Summary
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.
Attributes Documentation
- recovery_rate#
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().