CDS#
- class rateslib.instruments.CDS(*args, fixed_rate=NoInput.blank, premium_accrued=NoInput.blank, recovery_rate=NoInput.blank, discretization=NoInput.blank, **kwargs)#
Bases:
BaseDerivativeCreate a credit default swap composing a
CreditPremiumLegand aCreditProtectionLeg.- 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.
recovery_rate (float, Dual, Dual2, optional) – The assumed recovery rate on the protection leg 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, for the protection leg. Set by
defaults.kwargs (dict) – Required keyword arguments to
BaseDerivative.
Attributes Summary
If set will also set the
fixed_rateof the contained leg1.If set will also set the
float_spreadof contained leg1.If set will also set the
index_baseof the contained leg1.If set will also set the
fixed_rateof the contained leg2.If set will also set the
float_spreadof contained leg2.If set will also set the
index_baseof 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(vars[, curves, solver, fx, base, ...])Calculate delta risk of an Instrument against some exogenous user created Variables.
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.
Attributes Documentation
- fixed_rate#
If set will also set the
fixed_rateof the contained leg1.Note
fixed_rate,float_spread,leg2_fixed_rateandleg2_float_spreadare attributes only applicable to certainInstruments. AttributeErrors are raised if calling or setting these is invalid.- Type:
float or None
- float_spread#
If set will also set the
float_spreadof contained leg1.- Type:
float or None
- index_base#
If set will also set the
index_baseof the contained leg1.Note
index_baseandleg2_index_baseare attributes only applicable to certainInstruments. AttributeErrors are raised if calling or setting these is invalid.- Type:
float or None
- leg2_fixed_rate#
If set will also set the
fixed_rateof the contained leg2.- Type:
float or None
- leg2_float_spread#
If set will also set the
float_spreadof contained leg2.- Type:
float or None
- leg2_index_base#
If set will also set the
index_baseof the contained leg1.Note
index_baseandleg2_index_baseare attributes only applicable to certainInstruments. 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_ratethen None will be returned.
- 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=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#
Return the properties of all legs used in calculating 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
cashflowsmethod of the Instrument.solver (Solver, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.fx (float, FXRates, FXForwards, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.base (str, optional) – Argument input to the underlying
cashflowsmethod of the Instrument.kwargs (dict) – Additional arguments input the underlying
cashflowsmethod of the Instrument.
- Return type:
DataFrame
- delta(*args, **kwargs)#
Calculate the delta of the Instrument.
For arguments see
Sensitivities.delta().
- exo_delta(vars, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vars_scalar=NoInput.blank, vars_labels=NoInput.blank, **kwargs)#
Calculate delta risk of an Instrument against some exogenous user created Variables.
See What are exogenous variables? in the cookbook.
- Parameters:
vars (list[str]) – The variable tags which to determine sensitivities for.
curves (Curve, str or list of such, optional) –
A single
Curveor id or a list of such. A list defines the following curves in the order:solver (Solver, optional) – The
Solverthat calibrates Curves from given Instruments.fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fx_rateis anFXRatesorFXForwardsobject.local (bool, optional) – If True will ignore
base- this is equivalent to settingbaseto None. Included only for argument signature consistent with npv.vars_scalar (list[float], optional) – Scaling factors for each variable, for example converting rates to basis point etc. Defaults to ones.
vars_labels (list[str], optional) – Alternative names to relabel variables in DataFrames.
- Return type:
DataFrame
- 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.
- Parameters:
curves (Curve, str or list of such) –
A single
Curveor id or a list of such. A list defines the following curves in the order:solver (Solver, optional) –
The numerical
Solverthat constructsCurvefrom calibrating instruments.Note
The arguments
fxandbaseare unused by single currency derivatives rates calculations.
- Return type:
Notes
The arguments
fxandbaseare unused by single currency derivatives rates calculations.