CreditPremiumLeg#
- class rateslib.legs.CreditPremiumLeg(*args, fixed_rate=NoInput.blank, premium_accrued=NoInput.blank, **kwargs)#
Bases:
BaseLeg,_FixedLegMixinCreate a credit premium leg composed of
CreditPremiumPeriods.- Parameters:
args (tuple) – Required positional args to
BaseLeg.fixed_rate (float, optional) – The credit spread applied to determine cashflows in percentage points (i.e 50bps = 0.50). Can be left unset and designated later, perhaps after a mid-market rate for all periods has been calculated.
premium_accrued (bool, optional) – Whether the premium is accrued within the period to default.
kwargs (dict) – Required keyword arguments to
BaseLeg.
Notes
The NPV of a credit premium 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]: premium_leg = CreditPremiumLeg( ...: dt(2022, 1, 1), "9M", "Q", ...: fixed_rate=2.60, ...: notional=1000000, ...: ) ...: In [4]: premium_leg.cashflows(hazard_curve, disc_curve) Out[4]: Type Period Ccy Acc Start Acc End Payment Convention DCF Notional DF Collateral Rate Survival Cashflow NPV FX Rate NPV Ccy 0 CreditPremiumPeriod Regular USD 2022-01-01 2022-04-01 2022-04-03 ACT360 0.25 1000000.00 0.99 None 2.60 1.00 -6500.00 -6462.99 1.00 -6462.99 1 CreditPremiumPeriod Regular USD 2022-04-01 2022-07-01 2022-07-03 ACT360 0.25 1000000.00 0.99 None 2.60 1.00 -6572.22 -6493.89 1.00 -6493.89 2 CreditPremiumPeriod Regular USD 2022-07-01 2022-10-01 2022-10-03 ACT360 0.26 1000000.00 0.98 None 2.60 1.00 -6644.44 -6523.71 1.00 -6523.71 In [5]: premium_leg.npv(hazard_curve, disc_curve) Out[5]: -19480.592647251025
Methods Summary
accrued(settlement)Calculate the amount of premium accrued until a specific date within the relevant Period.
analytic_delta(*args, **kwargs)Return the analytic delta of the CreditPremiumLeg via summing all periods.
cashflows(*args, **kwargs)Return the properties of the CreditPremiumLeg used in calculating cashflows.
npv(*args, **kwargs)Return the NPV of the CreditPremiumLeg via summing all periods.
Methods Documentation
- accrued(settlement)#
Calculate the amount of premium accrued until a specific date within the relevant Period.
- Parameters:
settlement (datetime) – The date against which accrued is measured.
- Return type:
float
- analytic_delta(*args, **kwargs)#
Return the analytic delta of the CreditPremiumLeg via summing all periods.
For arguments see
BasePeriod.analytic_delta().
- cashflows(*args, **kwargs)#
Return the properties of the CreditPremiumLeg used in calculating cashflows.
For arguments see
BasePeriod.cashflows().
- npv(*args, **kwargs)#
Return the NPV of the CreditPremiumLeg via summing all periods.
For arguments see
BasePeriod.npv().