CDS#

class rateslib.instruments.CDS(*args, fixed_rate=NoInput.blank, premium_accrued=NoInput.blank, **kwargs)#

Bases: BaseDerivative

Create a credit default swap composing a CreditPremiumLeg and a CreditProtectionLeg.

Parameters:
  • args (dict) – Required positional args to BaseDerivative.

  • fixed_rate (float or None, optional) – The rate applied to determine the cashflow on the premium leg. If None, can be set later, typically after a mid-market rate for all periods has been calculated. Entered in percentage points, e.g. 50bps is 0.50.

  • premium_accrued (bool, optional) – Whether the premium is accrued within the period to default.

  • kwargs (dict) – Required keyword arguments to BaseDerivative.

Attributes Summary

fixed_rate

If set will also set the fixed_rate of the contained leg1.

float_spread

If set will also set the float_spread of contained leg1.

index_base

If set will also set the index_base of the contained leg1.

leg2_fixed_rate

If set will also set the fixed_rate of the contained leg2.

leg2_float_spread

If set will also set the float_spread of contained leg2.

leg2_index_base

If set will also set the index_base of the contained leg1.

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 a leg of the derivative object.

analytic_rec_risk(*args, **kwargs)

Return the analytic recovery risk of the derivative object.

cashflows([curves, solver, fx, base])

Return the properties of all legs used in calculating cashflows.

cashflows_table([curves, solver, fx, base])

Aggregate the values derived from a cashflows() method on an Instrument.

delta(*args, **kwargs)

Calculate the delta of the Instrument.

exo_delta(*args, **kwargs)

Calculate the delta of the Instrument, measured against user defined Variable s.

gamma(*args, **kwargs)

Calculate the gamma of the Instrument.

npv([curves, solver, fx, base, local])

Return the NPV of the derivative by summing legs.

rate([curves, solver, fx, base])

Return the mid-market credit spread of the CDS in percentage points.

Attributes Documentation

fixed_rate#

If set will also set the fixed_rate of the contained leg1.

Note

fixed_rate, float_spread, leg2_fixed_rate and leg2_float_spread are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

float_spread#

If set will also set the float_spread of contained leg1.

Type:

float or None

index_base#

If set will also set the index_base of the contained leg1.

Note

index_base and leg2_index_base are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

leg2_fixed_rate#

If set will also set the fixed_rate of the contained leg2.

Type:

float or None

leg2_float_spread#

If set will also set the float_spread of contained leg2.

Type:

float or None

leg2_index_base#

If set will also set the index_base of the contained leg1.

Note

index_base and leg2_index_base are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

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 or None

Notes

If the CDS is unpriced, i.e. there is no specified fixed_rate then None will be returned.

analytic_delta(*args, **kwargs)#

Return the analytic delta of a leg of the derivative object.

See BaseDerivative.analytic_delta().

analytic_rec_risk(*args, **kwargs)#

Return the analytic recovery risk of the derivative object.

See BaseDerivative.analytic_delta().

cashflows(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#

Return the properties of all legs used in calculating cashflows.

See BaseDerivative.cashflows().

cashflows_table(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, **kwargs)#

Aggregate the values derived from a cashflows() method on an Instrument.

Parameters:
  • curves (CurveType, str or list of such, optional) – Argument input to the underlying cashflows method of the Instrument.

  • solver (Solver, optional) – Argument input to the underlying cashflows method of the Instrument.

  • fx (float, FXRates, FXForwards, optional) – Argument input to the underlying cashflows method of the Instrument.

  • base (str, optional) – Argument input to the underlying cashflows method of the Instrument.

  • kwargs (dict) – Additional arguments input the underlying cashflows method of the Instrument.

Return type:

DataFrame

delta(*args, **kwargs)#

Calculate the delta of the Instrument.

For arguments see Sensitivities.delta().

exo_delta(*args, **kwargs)#

Calculate the delta of the Instrument, measured against user defined Variable s.

For arguments see Sensitivities.exo_delta().

gamma(*args, **kwargs)#

Calculate the gamma of the Instrument.

For arguments see Sensitivities.gamma().

npv(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False)#

Return the NPV of the derivative by summing legs.

See BaseDerivative.npv().

rate(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#

Return the mid-market credit spread of the CDS in percentage points.

Parameters:
  • curves (Curve, str or list of such) –

    A single Curve or id or a list of such. A list defines the following curves in the order:

    • Forecasting Curve for floating leg.

    • Discounting Curve for both legs.

  • solver (Solver, optional) –

    The numerical Solver that constructs Curve from calibrating instruments.

    Note

    The arguments fx and base are unused by single currency derivatives rates calculations.

Return type:

float, Dual or Dual2

Notes

The arguments fx and base are unused by single currency derivatives rates calculations.