Cds
financepy.products.credit.cds
Classes
CDS
CDS(step_in_dt: financepy.utils.date.Date, maturity_dt_or_tenor: financepy.utils.date.Date | str, running_cpn: float, notional: float = 1000000, long_protect: bool = True, freq_type: financepy.utils.frequency.FrequencyTypes = <FrequencyTypes.QUARTERLY: 4>, accrual_dc_type: financepy.utils.day_count.DayCountTypes = <DayCountTypes.ACT_360: 8>, cal_type: financepy.utils.calendar.CalendarTypes | list | tuple = <CalendarTypes.WEEKEND: 2>, bd_type: financepy.utils.calendar.BusDayAdjustTypes = <BusDayAdjustTypes.FOLLOWING: 2>, dg_type: financepy.utils.calendar.DateGenRuleTypes = <DateGenRuleTypes.BACKWARD: 2>)
A class which manages a Credit Default Swap. It performs schedule
generation and the valuation and risk management of CDS.
Methods
value
value(self, value_dt, issuer_curve, contract_recovery_rate, pv01_method=0, prot_method=0, num_steps_per_year=25)
Valuation of a CDS contract on a specific valuation date given
an issuer curve and a contract recovery rate.
spread_dv01
spread_dv01(self, value_dt, issuer_curve, contract_recovery_rate, pv01_method=0, prot_method=0, num_steps_per_year=25)
Calculation of the change in the value of the CDS contract for a
one basis point change in the level of the CDS curve.
ir_dv01
ir_dv01(self, value_dt: financepy.utils.date.Date, issuer_curve, contract_recovery_rate, pv01_method: int = 0, prot_method: int = 0, num_steps_per_year=25)
Calculation of the interest DV01 based on a simple bump of
the discount factors and reconstruction of the CDS curve.
recovery_dv01
recovery_dv01(self, value_dt: financepy.utils.date.Date, issuer_curve, contract_recovery_rate: float, pv01_method: int = 0, prot_method: int = 0, num_steps_per_year=25)
PV change when contract and curve recovery both increase by 1%.
The market CDS calibration quotes and discount curve are held fixed.
Returns:
PV(curve recovery + 0.01, contract recovery + 0.01)
- PV(curve recovery, contract recovery)
upfront
upfront(self, value_dt, settle_dt, issuer_curve, contract_recovery_rate, pv01_method=0, prot_method=0, num_steps_per_year=25)
Return clean percentage PV expressed on T+3 settlement date.
cash_settlement_amount
cash_settlement_amount(self, value_dt, settle_dt, issuer_curve, contract_recovery_rate, pv01_method=0, prot_method=0, num_steps_per_year=25)
Return dirty amount paid on the T+3 settlement date.
clean_price
clean_price(self, value_dt, issuer_curve, contract_recovery_rate, pv01_method=0, prot_method=0, num_steps_per_year=25)
Value of the CDS contract excluding accrued interest.
accrued_days
accrued_days(self, settle_dt)
Number of days between the previous coupon and the currrent step
in date.
accrued_interest
accrued_interest(self, settle_dt)
Calculate the amount of accrued interest that has accrued from the
previous cpn date (PCD) to the step_in_dt of the CDS contract.
prot_leg_pv
prot_leg_pv(self, value_dt, issuer_curve, contract_recovery_rate=0.4, num_steps_per_year=25, prot_method=0)
Calculates the protection leg PV of the CDS by calling into the
fast NUMBA code that has been defined above.
get_pcd
get_pcd(self, value_dt)
Get the previous coupon date before the value date
rpv01
rpv01(self, value_dt, issuer_curve, pv01_method=0)
The risky_pv01 is the present value of a risky one dollar paid on
the premium leg of a CDS contract.
premium_leg_pv
premium_leg_pv(self, value_dt, issuer_curve, pv01_method=0)
Value of the premium leg of a CDS.
par_spread
par_spread(self, value_dt, issuer_curve, contract_recovery_rate=0.4, num_steps_per_year=25, pv01_method=0, prot_method=0)
Breakeven CDS cpn that would make the value of the CDS contract
equal to zero.
value_fast_approx
value_fast_approx(self, value_dt, flat_cont_interest_rate, flat_cds_curve_spread, curve_recovery=0.4, contract_recovery_rate=0.4, bump_size=0.0001, recovery_bump_size=0.01)
Fast approximate CDS valuation using flat hazard and discount curves.
The hazard rate is implied from the flat CDS spread via the credit
triangle ``h = spread / (1 - curve_recovery)`` and both survival
and discounting are treated as flat exponentials. The premium leg
ignores the actual coupon schedule; accrual-on-default is captured
only heuristically through the 365/360 clean-RPV01 adjustment. All
PVs are in currency units of the contract notional.
Args:
value_dt: Valuation date (a ``Date``). Scalar only.
flat_cont_interest_rate: Flat continuously compounded discount
rate. Scalar or array-like.
flat_cds_curve_spread: Flat CDS par spread (decimal, e.g. 0.01
for 100 bp). Must be non-negative. Scalar or array-like.
curve_recovery: Recovery rate used to imply the hazard rate
from the spread. Must lie in ``[0, 1)``. Scalar or
array-like.
contract_recovery_rate: Contractual recovery rate used on the
protection leg. Must lie in ``[0, 1]``. Scalar or
array-like.
bump_size: Absolute bump applied to the spread and to the
interest rate for the finite-difference sensitivities.
Scalar or array-like, strictly positive.
recovery_bump_size: Absolute bump applied to the contractual
recovery rate for the recovery sensitivity. Scalar or
array-like, strictly positive.
Returns:
A tuple ``(full_pv, clean_pv, spread_dv01, ir_dv01, recovery01)``:
full_pv: Clean PV plus accrued interest.
clean_pv: PV excluding accrued interest.
credit01: PV change for a 1 bp increase in the CDS spread.
ir01: PV change for a 1 bp increase in the interest rate.
recovery01: PV change for a 1 percentage-point increase in
the contractual recovery.
Elements are floats if every input was scalar, otherwise ndarrays
with the broadcast shape of the inputs. The sensitivities are
one-sided (upward) finite differences, rescaled to the stated
units whatever bump sizes are supplied. Recovery01 bumps the
recovery assumption everywhere it enters: the hazard rate is
re-implied from the unchanged quoted spread under the bumped
curve recovery, and the contractual loss uses the bumped
contract recovery. It is therefore small and vanishes for an
at-market contract.
Raises:
FinError: If any input is invalid, the inputs cannot be
broadcast together, or the contract has matured.
print_payments
print_payments(self, value_dt, issuer_curve)
We only print payments after the current valuation date
Generated automatically from the FinancePy source code.
Do not edit this file manually.