CreditPremiumLeg#
- class rateslib.legs.CreditPremiumLeg(*args, fixed_rate=NoInput.blank, premium_accrued=NoInput.blank, **kwargs)#
Bases:
_FixedLegMixin
,BaseLeg
Create a credit premium leg composed of
CreditPremiumPeriod
s.- 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( ...: schedule=Schedule(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.250000 1000000.0 0.994921 None 2.6 0.998765 -6500.000000 -6462.991315 1.0 -6462.991315 1 CreditPremiumPeriod Regular USD 2022-04-01 2022-07-01 2022-07-03 Act360 0.252778 1000000.0 0.989922 None 2.6 0.997517 -6572.222222 -6493.894505 1.0 -6493.894505 2 CreditPremiumPeriod Regular USD 2022-07-01 2022-10-01 2022-10-03 Act360 0.255556 1000000.0 0.984894 None 2.6 0.996258 -6644.444444 -6523.706828 1.0 -6523.706828 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()
.