# bndkrdur

Bond key rate duration given zero curve

## Syntax

```KRDUR = bndkrdur(ZeroData, CouponRate,Settle, Maturity)
KRDUR = bndkrdur(ZeroData, CouponRate, Settle,Maturity, 'Parameter1', Value1, 'Parameter2',Value2, ...)
```

## Arguments

 `ZeroData` Zero curve represented as a `numRates`-by-`2` matrix where the first column is a MATLAB® date number and the second column is accompanying zero rates. `CouponRate` `numBonds`-by-`1` vector of coupon rates in decimal form. `Settle` Scalar MATLAB date number for the settlement date for all the bonds and the zero data. `Settle` must be the same settlement date for all the bonds and the zero curve. `Maturity ` `numBonds`-by-`1` vector of maturity dates. `Period` (Optional) Coupons per year of the bond. A vector of integers. Acceptable values are `0`, `1`, `2` (default), `3`, `4`, `6`, and `12`. `InterpMethod` (Optional) Interpolation method used to obtain points from the zero curve. Acceptable values are: `'linear'` (default)`'cubic'` `'pchip'` `ShiftValue` (Optional) Scalar value that zero curve is shifted up and down to compute duration. Default is .01 (100 basis points). `KeyRates` (Optional) Rates to perform the duration calculation, specified as a time to maturity. By default, `KeyRates` is set to each of the zero dates. `CurveCompounding` (Optional) Compounding frequency of the curve. Default is semiannual. `CurveBasis` (Optional) Basis of the curve, where the choices are identical to `Basis` below. Default is `0` (actual/actual). `Basis` (Optional) Day-count basis of the bond instrument. A vector of integers: 0 = actual/actual (default)1 = 30/360 (SIA)2 = actual/3603 = actual/3654 = 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/252For more information, see basis. `EndMonthRule` (Optional) End-of-month rule. This rule applies only when `Maturity` is an end-of-month date for a month having 30 or fewer days. The values are:`0` = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. `1` = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month. `IssueDate` (Optional) Date when a bond was issued. `FirstCouponDate` (Optional) Date when a bond makes its first coupon payment; used when bond has an irregular first coupon period. When `FirstCouponDate` and `LastCouponDate` are both specified, `FirstCouponDate` takes precedence in determining the coupon payment structure. If you do not specify a `FirstCouponDate`, the cash flow payment dates are determined from other inputs. `LastCouponDate` (Optional) Last coupon date of a bond before the maturity date; used when bond has an irregular last coupon period. In the absence of a specified `FirstCouponDate`, a specified `LastCouponDate` determines the coupon structure of the bond. The coupon structure of a bond is truncated at the `LastCouponDate`, regardless of where it falls, and is followed only by the bond's maturity cash flow date. If you do not specify a `LastCouponDate`, the cash flow payment dates are determined from other inputs. `StartDate` (Optional) Date when a bond actually starts (the date from which a bond cash flow is considered). To make an instrument forward-starting, specify this date as a future date. If you do not specify `StartDate`, the effective start date is the `Settle` date. `Face` (Optional) Face or par value. Default = `100`. `Face` has no impact on key rate duration.

 Note:   You must enter the optional arguments as parameter/value pairs.

## Description

`KRDUR = bndkrdur(ZeroData, CouponRate, Settle, Maturity)`

```KRDUR = bndkrdur(ZeroData, CouponRate, Settle, Maturity, 'Parameter1', Value1, 'Parameter2', Value2, ...)```

The output argument `KRDUR` is a `numBonds`-by-`numRates` matrix of key rate durations.

`bndkrdur` computes the key rate durations for one or more bonds given a zero curve and a set of key rates. By default, the key rates are each of the zero curve rates. For each key rate, the duration is computed by shifting the zero curve up and down by a specified amount (`ShiftValue`) at that particular key rate, computing the present value of the bond in each case with the new zero curves, and then evaluating the following:

 Note:   The shift to the curve is computed by shifting the particular key rate by the `ShiftValue` and then interpolating the values of the curve in the interval between the previous and next key rates. For the first key rate, any curve values before the date are equal to the `ShiftValue`; likewise, for the last key rate, any curve values after the date are equal to the `ShiftValue`.

## Examples

collapse all

### Find the Bond Key Rate Duration Given the Zero Curve

This example shows how to compute the key rate duration of a bond for key rate times of 2, 5, 10, and 30 years.

```ZeroRates = [0.0476 .0466 .0465 .0468 .0473 .0478 ... .0493 .0539 .0572 .0553 .0530]'; ZeroDates = daysadd('31-Dec-1998',[30 360 360*2 360*3 360*5 ... 360*7 360*10 360*15 360*20 360*25 360*30],1); ZeroData = [ZeroDates ZeroRates]; krdur = bndkrdur(ZeroData,.0525,'12/31/1998',... '11/15/2028','KeyRates',[2 5 10 30]) ```
```krdur = 0.2986 0.8791 4.1353 9.5814 ```

## References

Golub, B.W. and L.M. Tilman, Risk Management: Approaches for Fixed Income Markets Wiley, 2000.

Tuckman, B. Fixed Income Securities: Tools for Today's Markets Wiley, 2002.