quantlib.instruments.credit_default_swap.CreditDefaultSwap¶
- class CreditDefaultSwap(Protection side, double notional, double spread, Schedule schedule, BusinessDayConvention payment_convention, DayCounter day_counter, bool settles_accrual=True, bool pays_at_default_time=True, Date protection_start=Date(), DayCounter last_period_day_counter=Actual360(True), bool rebates_accrual=True, Date trade_date=Date(), Natural cash_settlement_days=3)¶
Bases:
Instrument
Credit default swap as running-spread only
- Parameters:
side (int or {BUYER, SELLER}) – Whether the protection is bought or sold.
notional (float) – Notional value
spread (float) – Running spread in fractional units.
schedule (
Schedule
) – Coupon schedule.payment_convention (int) – Business-day convention for payment-date adjustment.
day_counter (
DayCounter
) – Day-count convention for accrual.settles_accrual (bool, optional) – Whether or not the accrued coupon is due in the event of a default.
pays_at_default_time (bool, optional) – If set to True, any payments triggered by a default event are due at default time. If set to False, they are due at the end of the accrual period.
protection_start (
Date
, optional) – The first date where a default event will trigger the contract.last_period_day_counter (
DayCounter
, optional) – Day-count convention for accrual in last periodrebates_accrual (bool, optional) – The protection seller pays the accrued scheduled current coupon at the start of the contract. The rebate date is not provided but computed to be two days after protection start.
trade_date (
Date
) – The contract’s trade date. It will be used with thecash_settlement_days
to determine the date on which the cash settlement amount is paid. If not given, the trade date is guessed from the protection start date andschedule
date generation rule.cash_settlement_days (int) – The number of business days from
trade_date
to cash settlement date.
Notes
This instrument currently assumes that the issuer did not default until today’s date.
Warning
if
Settings.include_reference_date_cashflows
is set toTrue
, payments occurring at the settlement date of the swap might be included in the NPV and therefore affect the fair-spread calculation. This might not be what you want.- __init__()¶
Credit default swap as running-spread only
Methods
Credit default swap as running-spread only
conventional_spread
(self, Real recovery, ...)from_upfront
(cls, Protection side, ...)Credit default swap quoted as upfront and running spread
implied_hazard_rate
(self, Real target_npv, ...)set_pricing_engine
(self, PricingEngine engine)Sets the pricing engine.
Attributes
accrual
accrual_rebate_npv
cash_settlement_days
coupon_leg_bps
coupon_leg_npv
coupons
default_leg_npv
Returns the running spread that, given the quoted recovery rate, will make the running-only CDS have an NPV of 0.
Returns the upfront spread that, given the running spread and the quoted recovery rate, will make the instrument have an NPV of 0.
is_expired
net_present_value
Instrument net present value.
notional
npv
Shortcut to the net_present_value property.
pays_at_default_time
protection_end_date
protection_start_date
rebates_accrual
running_spread
settles_accrual
side
trade_date
upfront
upfront_bps
upfront_npv
valuation_date
- conventional_spread(self, Real recovery, YieldTermStructure yts, DayCounter dc=Actual365Fixed(), PricingModel model=PricingModel.Midpoint)¶
- fair_spread¶
Returns the running spread that, given the quoted recovery rate, will make the running-only CDS have an NPV of 0.
Notes
This calculation does not take any upfront into account, even if one was given.
- fair_upfront¶
Returns the upfront spread that, given the running spread and the quoted recovery rate, will make the instrument have an NPV of 0.
- classmethod from_upfront(cls, Protection side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention payment_convention, DayCounter day_counter, bool settles_accrual=True, bool pays_at_default_time=True, Date protection_start=Date(), Date upfront_date=Date(), DayCounter last_period_day_counter=Actual360(True), bool rebates_accrual=True, Date trade_date=Date(), Natural cash_settlement_days=3)¶
Credit default swap quoted as upfront and running spread
- Parameters:
side (int or {BUYER, SELLER}) – Whether the protection is bought or sold.
notional (float) – Notional value
upront (float) – Upfront payment in fractional units.
spread (float) – Running spread in fractional units.
schedule (
Schedule
) – Coupon schedule.payment_convention (int) – Business-day convention for payment-date adjustment.
day_counter (
DayCounter
) – Day-count convention for accrual.settles_accrual (bool, optional) – Whether or not the accrued coupon is due in the event of a default.
pays_at_default_time (bool, optional) – If set to True, any payments triggered by a default event are due at default time. If set to False, they are due at the end of the accrual period.
protection_start (
Date
, optional) – The first date where a default event will trigger the contract.upfront_date (
Date
, optional) – Settlement date for the upfront and accrual rebate (if any) payments. Typically T+3, this is also the default value.last_period_day_counter (
DayCounter
, optional) – Day-count convention for accrual in last periodrebates_accrual (bool, optional) – The protection seller pays the accrued scheduled current coupon at the start of the contract. The rebate date is not provided but computed to be two days after protection start.
trade_date (
Date
) – The contract’s trade date. It will be used with the cash_settlement_days to determine the date on which the cash settlement amount is paid. If not given, the trade date is guessed from the protection start date and schedule date generation rule.cash_settlement_days (int) – The number of business days from trade_date to cash settlement date.
- implied_hazard_rate(self, Real target_npv, YieldTermStructure yts, DayCounter dc=Actual365Fixed(), Real recovery_rate=0.4, Real accuracy=1e-8, PricingModel model=PricingModel.Midpoint)¶