hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.Instrument.Credit

Synopsis

Types

type CreditDefaultSwap = GenInstrument CCreditDefaultSwap Source #

An Instrument; see the hierarchy under GenInstrument.

type SyntheticCDO = GenInstrument CSyntheticCDO Source #

An Instrument; see the hierarchy under GenInstrument.

type NthToDefault = GenInstrument CNthToDefault Source #

An Instrument; see the hierarchy under GenInstrument.

Constructors

Credit-default swaps and options

creditDefaultSwap Source #

Arguments

:: ProtectionSide 
-> Double

notional

-> Double

spread

-> Schedule 
-> BusinessDayConvention 
-> DayCounter 
-> Bool

settlesAccrual

-> Bool

paysAtDefaultTime

-> Maybe Day

protectionStart

-> Claim 
-> DayCounter

lastPeriodDayCounter

-> Bool

rebatesAccrual

-> Maybe Day

tradeDate

-> Word

cashSettlementDays

-> IO CreditDefaultSwap 

CDS quoted as running-spread only. side Whether the protection is bought or sold. notional Notional value spread Running spread in fractional units. schedule Coupon schedule. paymentConvention Business-day convention for payment-date adjustment. dayCounter Day-count convention for accrual. settlesAccrual Whether or not the accrued coupon is due in the event of a default. paysAtDefaultTime 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. protectionStart The first date where a default event will trigger the contract.

creditDefaultSwapWithUpfront Source #

Arguments

:: ProtectionSide 
-> Double

notional

-> Double

upfront

-> Double

spread

-> Schedule 
-> BusinessDayConvention 
-> DayCounter 
-> Bool

settlesAccrual

-> Bool

paysAtDefaultTime

-> Maybe Day

protectionStart

-> Maybe Day

upfrontDate

-> Claim 
-> DayCounter

lastPeriodDayCounter

-> Bool

rebatesAccrual

-> Maybe Day

tradeDate

-> Word

cashSettlementDays

-> IO CreditDefaultSwap 

CDS quoted as upfront and running spread. side Whether the protection is bought or sold. notional Notional value upfront Upfront in fractional units. spread Running spread in fractional units. schedule Coupon schedule. paymentConvention Business-day convention for payment-date adjustment. dayCounter Day-count convention for accrual. settlesAccrual Whether or not the accrued coupon is due in the event of a default. paysAtDefaultTime 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. protectionStart The first date where a default event will trigger the contract. upfrontDate Settlement date for the upfront payment.

cdsOption Source #

Arguments

:: CreditDefaultSwap 
-> Exercise 
-> Bool

knocksOut

-> IO CdsOption 

An option giving the right to enter the underlying CDS, buying protection and paying coupon.

Portfolio credit

syntheticCdo :: TrancheBasket -> ProtectionSide -> Schedule -> Double -> Double -> DayCounter -> BusinessDayConvention -> Maybe Double -> IO SyntheticCDO Source #

A synthetic CDO tranche over a tranche-loss basket. notional overrides the basket tranche.

nthToDefault :: DigitalBasket -> Word -> ProtectionSide -> Schedule -> Double -> Double -> DayCounter -> Double -> Bool -> IO NthToDefault Source #

Protection against the n-th default in a DigitalBasket.

Inspectors

Credit-default swaps and options

atmRate :: CdsOption -> IO Double Source #

The fair running spread implied by the underlying CDS's term structures at the option's exercise.

impliedVolatility Source #

Arguments

:: CdsOption 
-> Double

price

-> GenYieldTermStructure y 
-> GenDefaultProbabilityTermStructure d 
-> Double

recoveryRate

-> Double

accuracy

-> Word

maxEvaluations

-> Double

minVol

-> Double

maxVol

-> IO Double 

Volatility that reproduces a given option price under the pricing engine's volatility model.

riskyAnnuity :: CdsOption -> IO Double Source #

The risky annuity used to convert between the option's price and its implied volatility.

accrualRebateNpv :: CreditDefaultSwap -> IO Double Source #

NPV of the rebate paid/received on an early default for the fraction of the accrual period elapsed since the last coupon date; zero unless the CDS was constructed with rebatesAccrual.

conventionalSpread Source #

Conventional/standard upfront-to-spread conversion. Under a standard ISDA model and a set of standardised instrument characteristics, it is the running only quoted spread that will make a CDS contract have an NPV of 0 when quoted for that running only spread. Refer to: "ISDA Standard CDS converter specification." May 2009.The conventional recovery rate to apply in the calculation is as specified by ISDA, not necessarily equal to the market-quoted one. It is typically 0.4 for SeniorSec and 0.2 for subordinate.The conversion employs a flat hazard rate. As a result, you will not recover the market quotes.This method performs the calculation with the instrument characteristics. It will coincide with the ISDA calculation if your object has the standard characteristics. Notably: The calendar should have no bank holidays, just weekends.The yield curve should be LIBOR piecewise constant in fwd rates, with a discount factor of 1 on the calculation date, which coincides with the trade date.Convention should be Following for yield curve and contract cashflows.The CDS should pay accrued and mature on standard IMM dates, settle on trade date +1 and upfront settle on trade date +3.

couponLegBps :: CreditDefaultSwap -> IO Double Source #

Returns the variation of the fixed-leg value given a one-basis-point change in the running spread.

couponLegNpv :: CreditDefaultSwap -> IO Double Source #

NPV of the coupon (premium) leg.

coupons :: CreditDefaultSwap -> IO Leg Source #

The coupon-leg cash flows of the CDS.

defaultLegNpv :: CreditDefaultSwap -> IO Double Source #

NPV of the default (protection) leg.

fairUpfront :: CreditDefaultSwap -> IO Double Source #

Returns the upfront spread that, given the running spread and the quoted recovery rate, will make the instrument have an NPV of 0.

impliedHazardRate Source #

Arguments

:: CreditDefaultSwap 
-> Double

targetNPV

-> GenYieldTermStructure y 
-> DayCounter 
-> Double

recoveryRate

-> Double

accuracy

-> PricingModel

model

-> IO Double 

Implied hazard rate calculation. This method performs the calculation with the instrument characteristics. It will coincide with the ISDA calculation if your object has the standard characteristics. Notably: The calendar should have no bank holidays, just weekends.The yield curve should be LIBOR piecewise constant in fwd rates, with a discount factor of 1 on the calculation date, which coincides with the trade date.Convention should be Following for yield curve and contract cashflows.The CDS should pay accrued and mature on standard IMM dates, settle on trade date +1 and upfront settle on trade date +3.

upfrontBps :: CreditDefaultSwap -> IO Double Source #

Returns the variation of the upfront payment value given a one-basis-point change in the upfront.

upfrontNpv :: CreditDefaultSwap -> IO Double Source #

NPV of the upfront payment.

Synthetic CDOs

fairPremium :: SyntheticCDO -> IO Double Source #

The fair running premium that makes the tranche's NPV zero (holding the upfront fixed).

fairUpfrontPremium :: SyntheticCDO -> IO Double Source #

The fair upfront premium that makes the tranche's NPV zero (holding the running rate fixed).

premiumValue :: SyntheticCDO -> IO Double Source #

NPV of the premium (running plus upfront) leg.

protectionValue :: SyntheticCDO -> IO Double Source #

NPV of the protection leg.

premiumLegNpv :: SyntheticCDO -> IO Double Source #

NPV of the premium (running plus upfront) leg, as a plain NPV (not divided by notional).

protectionLegNpv :: SyntheticCDO -> IO Double Source #

NPV of the protection leg, as a plain NPV.

cdoRemainingNotional :: SyntheticCDO -> IO Double Source #

Total outstanding tranche notional, not wiped out by realized losses.

implicitCorrelation Source #

Arguments

:: SyntheticCDO 
-> NonEmpty Double

recoveries

-> GenYieldTermStructure y

discountCurve

-> Double

targetNPV

-> Double

accuracy

-> IO Double 

The flat Gaussian-copula LHP correlation (constant along time and portfolio loss level) that makes the tranche's NPV equal targetNPV. recoveries One recovery rate per basket name, in the basket's own name order. discountCurve Curve to discount both legs with. targetNPV NPV to match; 0 for a fairly-priced tranche. accuracy Root-finding accuracy on the correlation.

Nth-to-default

ntdFairPremium :: NthToDefault -> IO Double Source #

The fair running premium that makes the nth-to-default swap's NPV zero.