# cdsprice

Determine price for credit default swap

## Syntax

``````[Price,AccPrem,PaymentDates,PaymentTimes,PaymentCF] = cdsprice(ZeroData,ProbData,Settle,Maturity,ContractSpread)``````
``````[Price,AccPrem,PaymentDates,PaymentTimes,PaymentCF] = cdsprice(___,Name,Value)``````

## Description

example

``````[Price,AccPrem,PaymentDates,PaymentTimes,PaymentCF] = cdsprice(ZeroData,ProbData,Settle,Maturity,ContractSpread)``` computes the price, or the mark-to-market value for CDS instruments.```

example

``````[Price,AccPrem,PaymentDates,PaymentTimes,PaymentCF] = cdsprice(___,Name,Value)``` adds optional name-value pair arguments.```

## Examples

collapse all

This example shows how to use `cdsprice` to compute the clean price for a CDS contract using the following data.

```Settle = '17-Jul-2009'; % valuation date for the CDS Zero_Time = [.5 1 2 3 4 5]'; Zero_Rate = [1.35 1.43 1.9 2.47 2.936 3.311]'/100; Zero_Dates = daysadd(Settle,360*Zero_Time,1); ZeroData = [Zero_Dates Zero_Rate]; ProbData = [daysadd(datenum(Settle),360,1), 0.0247]; Maturity = '20-Sep-2010'; ContractSpread = 135; [Price,AccPrem] = cdsprice(ZeroData,ProbData,Settle,Maturity,ContractSpread)```
```Price = 1.5461e+04 ```
```AccPrem = 10500 ```

## Input Arguments

collapse all

Zero rate data, specified as a `M`-by-`2` vector of dates and zero rates or an `IRDataCurve` object of zero rates.

When `ZeroData` is an `IRDataCurve` object, `ZeroCompounding` and `ZeroBasis` are implicit in `ZeroData` and are redundant inside this function. In this case, specify these optional parameters when constructing the `IRDataCurve` object before using the `cdsprice` function.

For more information on an `IRDataCurve` object, see Creating an IRDataCurve Object (Financial Instruments Toolbox).

Data Types: `double` | `struct`

Default probability values, specified as a `P`-by-`2` matrix with dates and corresponding cumulative default probability values.

Data Types: `double` | `char`

Settlement date, specified as a scalar serial date number or date character vector. The `Settle` date must be earlier than or equal to the dates in `Maturity`.

Data Types: `double` | `char`

Maturity date, specified as a `N`-by-`1` vector of serial date numbers or date character vectors.

Data Types: `double` | `char`

Contract spreads, specified as a `N`-by-`1` vector of spreads, expressed in basis points.

Data Types: `double`

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `[Price,AccPrem] = cdsprice(ZeroData,ProbData,Settle,Maturity,ContractSpread,'Basis',7,'BusDayConvention','previous')`

### Note

Any optional input of size `N`-by-`1` is also acceptable as an array of size `1`-by-`N`, or as a single value applicable to all contracts. Single values are internally expanded to an array of size `N`-by-`1`.

Recovery rate, specified as the comma-separated pair consisting of `'RecoveryRate'` and a `N`-by-`1` vector of recovery rates, specified as a decimal from `0` to `1`.

Data Types: `double`

Premium payment frequency, specified as the comma-separated pair consisting of `'Period'` and a `N`-by-`1` vector with values of `1`, `2`, `3`, `4`, `6`, or `12`.

Data Types: `double`

Day-count basis of the contract, specified as the comma-separated pair consisting of `'Basis'` and a positive integer using a `NINST`-by-`1` vector.

• 0 = actual/actual

• 1 = 30/360 (SIA)

• 2 = actual/360

• 3 = actual/365

• 4 = 30/360 (PSA)

• 5 = 30/360 (ISDA)

• 6 = 30/360 (European)

• 7 = actual/365 (Japanese)

• 8 = actual/actual (ICMA)

• 9 = actual/360 (ICMA)

• 10 = actual/365 (ICMA)

• 11 = 30/360E (ICMA)

• 12 = actual/365 (ISDA)

• 13 = BUS/252

Data Types: `double`

Business day conventions, specified as the comma-separated pair consisting of `'BusDayConvention'` and a character vector. The selection for business day convention determines how non-business days are treated. Non-business days are defined as weekends plus any other date that businesses are not open (for example, statutory holidays). Values are:

• `actual` — Non-business days are effectively ignored. Cash flows that fall on non-business days are assumed to be distributed on the actual date.

• `follow` — Cash flows that fall on a non-business day are assumed to be distributed on the following business day.

• `modifiedfollow` — Cash flows that fall on a non-business day are assumed to be distributed on the following business day. However if the following business day is in a different month, the previous business day is adopted instead.

• `previous` — Cash flows that fall on a non-business day are assumed to be distributed on the previous business day.

• `modifiedprevious` — Cash flows that fall on a non-business day are assumed to be distributed on the previous business day. However if the previous business day is in a different month, the following business day is adopted instead.

Data Types: `char`

Flag for accrued premiums paid upon default, specified as the comma-separated pair consisting of `'PayAccruedPremium'` and a `N`-by-`1` vector of Boolean flags that is `true` (default) if accrued premiums are paid upon default, `false` otherwise.

Data Types: `logical`

Contract notional values, specified as the comma-separated pair consisting of `'Notional'` and a `N`-by-`1`vector of integers. Use positive integer values for long positions and negative integer values for short positions.

Data Types: `double`

Number of days to take as time step for the numerical integration, specified as the comma-separated pair consisting of `'TimeStep'` and a nonnegative integer.

Data Types: `double`

Compounding frequency of the zero curve, specified as the comma-separated pair consisting of `'ZeroCmpounding'` and an integer with values:

• `1` — Annual compounding

• `2` — Semiannual compounding

• `3` — Compounding three times per year

• `4` — Quarterly compounding

• `6` — Bimonthly compounding

• `12` — Monthly compounding

• `−1` — Continuous compounding

Data Types: `double`

Basis of the zero curve, specified as the comma-separated pair consisting of `'ZeroBasis'` and an integer with values that are identical to `Basis`.

Data Types: `double`

## Output Arguments

collapse all

CDS clean prices, returned as a `N`-by-`1` vector.

Accrued premiums, returned as a `N`-by-`1` vector.

Payment dates, returned as a `N`-by-`numCF` matrix.

Payment times, returned as a `N`-by-`numCF` matrix of accrual fractions.

Payments, returned as a `N`-by-`numCF` matrix.

collapse all

### CDS Price

The price or mark-to-market (MtM) value of an existing CDS contract.

The CDS price is computed using the following formula:

```CDS price = Notional * (Current Spread - Contract Spread) * RPV01```

`Current Spread` is the current breakeven spread for a similar contract, according to current market conditions. `RPV01` is the 'risky present value of a basis point,' the present value of the premium payments, considering the default probability. This formula assumes a long position, and the right side is multiplied by -1 for short positions.

## Algorithms

The premium leg is computed as the product of a spread S and the risky present value of a basis point (`RPV01`). The `RPV01` is given by:

`$RPV01=\sum _{j=1}^{N}Z\left(tj\right)\Delta \left(tj-1,tj,B\right)Q\left(tj\right)$`

when no accrued premiums are paid upon default, and it can be approximated by

`$RPV01\approx \frac{1}{2}\sum _{j=1}^{N}Z\left(tj\right)\Delta \left(tj-1,tj,B\right)\left(Q\left(tj-1\right)+Q\left(tj\right)\right)$`

when accrued premiums are paid upon default. Here, t0 = `0` is the valuation date, and t1,...,tn = T are the premium payment dates over the life of the contract,T is the maturity of the contract, Z(t) is the discount factor for a payment received at time t, and Δ(tj-1, tj, B) is a day count between dates tj-1 and tj corresponding to a basis B.

The protection leg of a CDS contract is given by the following formula:

`$ProtectionLeg={\int }_{0}^{T}Z\left(\tau \right)\left(1-R\right)dPD\left(\tau \right)$`
`$\approx \left(1-R\right)\sum _{i=1}^{M}Z\left(\tau i\right)\left(PD\left(\tau i\right)-PD\left(\tau i-1\right)\right)$`
`$=\left(1-R\right)\sum _{i=1}^{M}Z\left(\tau i\right)\left(Q\left(\tau i-1\right)-Q\left(\tau i\right)\right)$`

where the integral is approximated with a finite sum over the discretization τ0 = `0`,τ1,...,τM = T.

If the spread of an existing CDS contract is SC, and the current breakeven spread for a comparable contract is S0, the current price, or mark-to-market value of the contract is given by:

`MtM` = `Notional` (S0SC)`RPV01`

This assumes a long position from the protection standpoint (protection was bought). For short positions, the sign is reversed.

## References

[1] Beumee, J., D. Brigo, D. Schiemert, and G. Stoyle. “Charting a Course Through the CDS Big Bang.” Fitch Solutions, Quantitative Research, Global Special Report. April 7, 2009.

[2] Hull, J., and A. White. “Valuing Credit Default Swaps I: No Counterparty Default Risk.” Journal of Derivatives. Vol. 8, pp. 29–40.

[3] O'Kane, D. and S. Turnbull. “Valuation of Credit Default Swaps.” Lehman Brothers, Fixed Income Quantitative Credit Research, April 2003.