Package 'credule'

Title: Credit Default Swap Functions
Description: It provides functions to bootstrap Credit Curves from market quotes (Credit Default Swap - CDS - spreads) and price Credit Default Swaps - CDS.
Authors: Bertrand Le Nezet [cre, aut, cph], Richard Brent [ctb, cph], John Burkardt [ctb, cph]
Maintainer: Bertrand Le Nezet <[email protected]>
License: MIT + file LICENSE
Version: 0.1.3
Built: 2024-11-06 03:10:11 UTC
Source: https://github.com/blenezet/credule

Help Index


Credit Default Swap pricing and Credit Curve bootstrapping

Description

Credit Curve boostrapping from market quotes (Credit Default Swap - CDS - spreads) and Credit Default Swap - CDS - pricing

Details

Package: credule
Type: Package
Version: 0.1.3
Date: 2015-08-03
License: MIT + file LICENSE

A Credit Default Swap (CDS) is a financial swap agreement that the seller of the CDS will compensate the buyer (usually the creditor of the reference loan) in the event of a loan default (by the debtor) or other credit event. This is to say that the seller of the CDS insures the buyer against some reference loan defaulting. The buyer of the CDS makes a series of payments (the CDS "fee" or "spread") to the seller and, in exchange, receives a payoff if the loan defaults. It was invented by Blythe Masters from JP Morgan in 1994.

April 8 2009 saw a "Big Bang" in the market for credit default swap (CDS) contracts and the way in which they are traded. Both contract and convention changes were implemented simultaneously. These changes were designed to make CDS more standardised to help support efforts for central clearing of CDS trades, make strides towards T+0 trade processing and facilitate operational efficiency.

The CDS "Big Bang" has introduced standardized coupon dates and maturity dates. The functions provided in this package do not use these "new" conventions (i.e. they use the conventions pre-April 2008); therefore it's not recommended to use them in a production context. In most cases the differences are marginal, therefore these functions are good enough for preliminary research.

See vignette("credule") for more details.

Note. I'm planning to update this package with proper CDS ISDA conventions handling at a later stage.

Author(s)

Bertrand Le Nezet Maintainer: Bertrand Le Nezet <bertrand dot lenezet at gmail dot com>

References

ISDA Standard CDS Example http://www.cdsmodel.com/cdsmodel/assets/cds-model/docs/Standard%20CDS%20Examples.pdf

CDS Bing Bang http://www.markit.com/assets/en/docs/markit-magazine/issue-4/60-cds-big-bang.pdf

Examples

library(credule)

yieldcurveTenor = c(1,2,3,4,5,7)
yieldcurveRate = c(0.0050,0.0070,0.0080,0.0100, 0.0120,0.0150)
creditcurveTenor = c(1,3,5,7)
creditcurveSP = c(0.99,0.98,0.95,0.92)
cdsTenors = c(1,3,5,7)
cdsSpreads = c(0.0050,0.0070,0.00100,0.0120)
premiumFrequency = 4
defaultFrequency = 12
accruedPremium = TRUE
RR = 0.40

# CDS pricing
res_price = priceCDS(yieldcurveTenor,
            yieldcurveRate,
            creditcurveTenor,
            creditcurveSP,
            cdsTenors,
            RR,
            premiumFrequency,
            defaultFrequency,
            accruedPremium
          )
res_price

# Credit curve bootstrapping from CDS spreads
res_bootstrap = bootstrapCDS(yieldcurveTenor,
             yieldcurveRate,
             res_price$tenor,
             res_price$spread,
             RR,
             premiumFrequency,
             defaultFrequency,
             accruedPremium)
res_bootstrap

Bootstrap a Credit Curve

Description

A function that bootstrap a credit curve from a set of Credit Default Swap spreads givent for various maturity.

Usage

bootstrapCDS(yieldcurveTenor,
			 yieldcurveRate,
			 cdsTenors,
			 cdsSpreads,
			 recoveryRate,
			 numberPremiumPerYear = c(4,2,1,12),
			 numberDefaultIntervalPerYear = 12,
			 accruedPremium = c(TRUE,FALSE))

Arguments

yieldcurveTenor

A double vector. Each value represents a tenor of the yield curve expressed in year (e.g. 1.0 for 1Y, 0.5 for 6M)

yieldcurveRate

A double vector. Each value represents the discount rate (continuously compounded) for a partical tenor (e.g. 0.005 means 0.5%, 0.02 means 2

cdsTenors

A double vector. Each value represents the maturity expressed in year of a Credit Default Swap which we want to price (e.g 5.0 means 5Y)

cdsSpreads

A double vector. Each value represents the CDS spread (expressed in decimal, e.g. 0.0050 represent 0.5% or 50 bp) for a given maturity

recoveryRate

A double. It represents the Recovery Rate in case of default (e.g 0.40 means 40% recovery which is a standard value for Senior Unsecured debt)

numberPremiumPerYear

An Integer. It represents the number of premiums paid per year. CDS premiums paid quaterly (i.e. numberPremiumPerYear=4) and sometimes semi-annually (i.e. numberPremiumPerYear=2)

numberDefaultIntervalPerYear

An Integer. It represents the number of timesteps used to perform the numerical integral required while computing the default leg value. It is shown that a monthly discretisation usually gives a good approximation (Ref. Valuation of Credit Default Swaps, Dominic O Kane and Stuart Turnbull)

accruedPremium

A boolean. If set to TRUE, the accrued premium will be taken into account in the calculation of the premium leg value.

Details

In brief, a CDS is used to transfer the credit risk of a reference entity (corporate or sovereign) from one party to another. In a standard CDS contract one party purchases credit protection from another party, to cover the loss of the face value of an asset following a credit event. A credit event is a legally defined event that typically includes bankruptcy, failure-to-pay and restructuring. This protection lasts until some specified maturity date. To pay for this protection, the protection buyer makes a regular stream of payments, known as the premium leg, to the protection seller. This size of these premium payments is calculated from a quoted default swap spread which is paid on the face value of the protection. These payments are made until a credit event occurs or until maturity, whichever occurs first.

Modeling Credit Using a Reduced-Form Approach The world of credit modelling is divided into two main approaches, one called the structural and the other called the reduced-form. In the structural approach, the idea is to characterize the default as being the consequence of some company event such as its asset value being insufficient to cover a repayment of debt.

Structural models are generally used to say at what spread corporate bonds should trade based on the internal structure of the firm. They therefore require information about the balance sheet of the firm and can be used to establish a link between pricing in the equity and debt markets. However, they are limited in at least three important ways: they are hard to calibrate because internal company data is only published at most four times a year; they generally lack the flexibility to fit exactly a given term structure of spreads; and they cannot be easily extended to price credit derivatives.

In the reduced-form approach, the credit event process is modeled directly by modeling the probability of the credit event itself. Using a security pricing model based on this approach, this probability of default can be extracted from market prices. Reduced form models also generally have the flexibility to refit the prices of a variety of credit instruments of different maturities. They can also be extended to price more exotic credit derivatives. It is for these reasons that they are used for credit derivative pricing.

See vignette("credule") for more details.

Value

Returns a Dataframe with 3 columns: tenor, survprob and hazrate. The tenor column contains the tenor value given in parameter cdsTenors, the survprob column gives the survival probability (in decimal) for each tenor (e.g. 0.98 menas 98%) and the hazrate column gives the non-cumulative hazard rate (intensity of the poisson process) for each tenor (e.g. 0.01 means 1% hazard rate).

Author(s)

Bertrand Le Nezet

Examples

library(credule)

yieldcurveTenor = c(1,2,3,4,5,7)
yieldcurveRate = c(0.0050,0.0070,0.0080,0.0100, 0.0120,0.0150)
cdsTenors = c(1,3,5,7)
cdsSpreads = c(0.0050,0.0070,0.0090,0.0110)
premiumFrequency = 4
defaultFrequency = 12
accruedPremium = TRUE
RR = 0.40

bootstrapCDS(yieldcurveTenor,
             yieldcurveRate,
             cdsTenors,
             cdsSpreads,
             RR,
             premiumFrequency,
             defaultFrequency,
             accruedPremium)

Credit Default Swap Pricing

Description

A function that calculates the spreads of several Credit Default Swaps (different maturities) from a yield curve and a credit curve.

Usage

priceCDS(yieldcurveTenor, yieldcurveRate, creditcurveTenor, creditcurveSP,
		 cdsTenors, recoveryRate, numberPremiumPerYear = c(4,2,1,12),
		 numberDefaultIntervalPerYear = 12, accruedPremium = c(TRUE,FALSE))

Arguments

yieldcurveTenor

A double vector. Each value represents a tenor of the yield curve expressed in year (e.g. 1.0 for 1Y, 0.5 for 6M)

yieldcurveRate

A double vector. Each value represents the discount rate (continuously compounded) for a partical tenor (e.g. 0.005 means 0.5%, 0.02 means 2%)

creditcurveTenor

A double vector. Each value represents a tenor of the credit curve expressed in year (e.g. 1.0 for 1Y, 0.5 for 6M)

creditcurveSP

A double vector. Each value represents the survival probability for a partical tenor (e.g. 0.98 means 98%)

cdsTenors

A double vector. Each value represents the maturity expressed in year of a Credit Default Swap which we want to price (e.g 5.0 means 5Y)

recoveryRate

A double. It represents the Recovery Rate in case of default (e.g 0.40 means 40% recovery which is a standard value for Senior Unsecured debt)

numberPremiumPerYear

An Integer. It represents the number of premiums paid per year. CDS premiums paid quaterly (i.e. numberPremiumPerYear=4) and sometimes semi-annually (i.e. numberPremiumPerYear=2)

numberDefaultIntervalPerYear

An Integer. It represents the number of timesteps used to perform the numerical integral required while computing the default leg value. It is shown that a monthly discretisation usually gives a good approximation (Ref. Valuation of Credit Default Swaps, Dominic O Kane and Stuart Turnbull)

accruedPremium

A boolean. If set to TRUE, the accrued premium will be taken into account in the calculation of the premium leg value.

Details

In brief, a CDS is used to transfer the credit risk of a reference entity (corporate or sovereign) from one party to another. In a standard CDS contract one party purchases credit protection from another party, to cover the loss of the face value of an asset following a credit event. A credit event is a legally defined event that typically includes bankruptcy, failure-to-pay and restructuring. This protection lasts until some specified maturity date. To pay for this protection, the protection buyer makes a regular stream of payments, known as the premium leg, to the protection seller. This size of these premium payments is calculated from a quoted default swap spread which is paid on the face value of the protection. These payments are made until a credit event occurs or until maturity, whichever occurs first.

Modeling Credit Using a Reduced-Form Approach The world of credit modelling is divided into two main approaches, one called the structural and the other called the reduced-form. In the structural approach, the idea is to characterize the default as being the consequence of some company event such as its asset value being insufficient to cover a repayment of debt.

Structural models are generally used to say at what spread corporate bonds should trade based on the internal structure of the firm. They therefore require information about the balance sheet of the firm and can be used to establish a link between pricing in the equity and debt markets. However, they are limited in at least three important ways: they are hard to calibrate because internal company data is only published at most four times a year; they generally lack the flexibility to fit exactly a given term structure of spreads; and they cannot be easily extended to price credit derivatives.

In the reduced-form approach, the credit event process is modeled directly by modeling the probability of the credit event itself. Using a security pricing model based on this approach, this probability of default can be extracted from market prices. Reduced form models also generally have the flexibility to refit the prices of a variety of credit instruments of different maturities. They can also be extended to price more exotic credit derivatives. It is for these reasons that they are used for credit derivative pricing.

See vignette("credule") for more details.

Value

Returns a Dataframe with 2 columns: tenor and spread. The tenor column contains the tenor value given in parameter cdsTenors, the spread column give the Credit Default Swap spreads (in decimal) for each tenor (e.g. 0.0050 is equivalent to 0.5% or 50 bp).

Author(s)

Bertrand Le Nezet

Examples

library(credule)

yieldcurveTenor = c(1,2,3,4,5,7)
yieldcurveRate = c(0.0050,0.0070,0.0080,0.0100, 0.0120,0.0150)
creditcurveTenor = c(1,3,5,7)
creditcurveSP = c(0.99,0.98,0.95,0.92)
cdsTenors = c(1,3,5,7)
cdsSpreads = c(0.0050,0.0070,0.00100,0.0120)
premiumFrequency = 4
defaultFrequency = 12
accruedPremium = TRUE
RR = 0.40

priceCDS(yieldcurveTenor,
            yieldcurveRate,
            creditcurveTenor,
            creditcurveSP,
            cdsTenors,
            RR,
            premiumFrequency,
            defaultFrequency,
            accruedPremium
          )