# Case: Hedging duration and convexity

This example constructs a bond portfolio to hedge the portfolio of Sensitivity of Bond Prices to Changes in Interest Rates. It assumes a long position in (holding) the portfolio, and that three other bonds are available for hedging. It chooses weights for these three other bonds in a new portfolio so that the duration and convexity of the new portfolio match those of the original portfolio. Taking a short position in the new portfolio, in an amount equal to the value of the first portfolio, partially hedges against parallel shifts in the yield curve. Recall that portfolio duration or convexity is a weighted average of the durations or convexities of the individual bonds in a portfolio. As in the previous example, this example uses modified duration in years and convexity in years. The hedging problem therefore becomes one of solving a system of linear equations.

## Step 1. Define three bonds available for hedging the original portfolio.

Specify values for the settlement date, maturity date, face value, and coupon rate. For simplicity, accept default values for the coupon payment periodicity (semiannual), end-of-month payment rule (rule in effect), and day-count basis (actual/actual). Also, synchronize the coupon payment structure to the maturity date (that is, no odd first or last coupon dates). Set any inputs for which defaults are accepted to empty matrices ([]) as placeholders where appropriate. The intent is to hedge against duration and convexity and constrain total portfolio price.

```Settle     = '19-July-2013';
Maturity   = ['15-Jun-2015'; '02-Oct-2020'; '01-Mar-2035'];
Face       = [1000; 1000; 1000];
CouponRate = [0.03; 0.04; 0.05];

% Also, specify the yield curve for each bond.
Yields = [0.01; 0.015; 0.02];
```

## Step 2. Calculate the price, modified duration in years, and convexity

```% The true price is quoted (clean price plus accrued interest.
[CleanPrice, AccruedInterest] = bndprice(Yields,CouponRate,Settle, Maturity, 2, 0, [], [], [], [], [], Face)

Prices  =  CleanPrice + AccruedInterest

Durations = bnddury(Yields, CouponRate, Settle, Maturity,2, 0, [], [], [], [], [], Face)

Convexities = bndconvy(Yields, CouponRate, Settle,Maturity, 2, 0, [], [], [], [], [], Face)
```
```CleanPrice =

1.0e+03 *

1.0377
1.1701
1.5245

AccruedInterest =

2.7869
11.8033
19.0217

Prices =

1.0e+03 *

1.0405
1.1819
1.5435

Durations =

1.8549
6.2999
14.7885

Convexities =

4.4113
46.2114
280.5535

```

## Step 3. Set up and solve the system of linear equations

Solution is the weights of the new bonds in a new portfolio with the same duration and convexity as the original portfolio. In addition, scale the weights to sum to 1; that is, force them to be portfolio weights. You can then scale this unit portfolio to have the same price as the original portfolio. Recall that the original portfolio duration and convexity are 10.3181 and 157.6346, respectively. Also, note that the last row of the linear system ensures that the sum of the weights is unity.

```A = [Durations'
Convexities'
1 1 1]

b = [ 10.3181
157.6346
1]

Weights = A\b
```
```A =

1.8549    6.2999   14.7885
4.4113   46.2114  280.5535
1.0000    1.0000    1.0000

b =

10.3181
157.6346
1.0000

Weights =

0.0061
0.5173
0.4766

```

## Step 4. Compute the duration and convexity of the hedge portfolio

```PortfolioDuration  = Weights' * Durations
PortfolioConvexity = Weights' * Convexities
```
```PortfolioDuration =

10.3181

PortfolioConvexity =

157.6346

```

## Step 5. Finally, scale the unit portfolio to match the value of the original portfolio

Find the number of bonds required to insulate against small parallel shifts in the yield curve.

```PortfolioValue = 100000;
HedgeAmounts   = Weights ./ Prices * PortfolioValue

%5 Step 6.   Compare the results.

% As required, the duration and convexity of the new portfolio are 10.3181 and 157.6346, respectively.
% The hedge amounts for bonds 1, 2, and 3 are -57.37, 71.70, and 216.27, respectively.
% Notice that the hedge matches the duration, convexity, and value (\$100,000) of the original portfolio.
% If you are holding that first portfolio, you can hedge by taking a short position in the new portfolio.
% Just as the approximations of the first example are appropriate only for small parallel shifts in the yield curve,
% the hedge portfolio is appropriate only for reducing the impact of small level changes in the term structure.
```
```HedgeAmounts =

0.5877
43.7699
30.8760

```