# Calibrating Caplets Using the Normal (Bachelier) Model

This example shows how to use `hwcalbycap` to calibrate market data with the Normal (Bachelier) model to price caplets. Use the Normal (Bachelier) model to perform calibrations when working with negative interest rates, strikes, and normal implied volatilities.

Consider a cap with these parameters:

```Settle = datetime(2016,12,30); Maturity = datetime(2019,12,30); Strike = -0.001075; Reset = 2; Principal = 100; Basis = 0;```

The caplets and market data for this example are defined as:

```capletDates = cfdates(Settle, Maturity, Reset, Basis); datestr(capletDates')```
```ans = 6x11 char array '30-Jun-2017' '30-Dec-2017' '30-Jun-2018' '30-Dec-2018' '30-Jun-2019' '30-Dec-2019' ```
```% Market data information MarketStrike = [-0.0013; 0]; MarketMat = [datetime(2017,6,30) ; datetime(2017,12,30) ; datetime(2018,6,30) ; datetime(2018,12,30) ; datetime(2019,6,30) ; datetime(2019,12,30)]; MarketVol = [0.184 0.2329 0.2398 0.2467 0.2906 0.3348; % First row in table corresponding to Strike 1 0.217 0.2707 0.2760 0.2814 0.3160 0.3508]; % Second row in table corresponding to Strike 2```

Define the `RateSpec` using `intenvset`.

```Rates= [-0.002210;-0.002020;-0.00182;-0.001343;-0.001075]; ValuationDate = datetime(2016,12,30); EndDates = [datetime(2017,6,30) ; datetime(2017,12,30) ; datetime(2018,6,30) ; datetime(2018,12,30) ; datetime(2019,12,30)]; Compounding = 2; Basis = 0; RateSpec = intenvset('ValuationDate', ValuationDate, ... 'StartDates', ValuationDate, 'EndDates', EndDates, ... 'Rates', Rates, 'Compounding', Compounding, 'Basis', Basis);```

Use `hwcalbycap` to find values for the volatility parameters `Alpha` and `Sigma` using the Normal (Bachelier) model.

```format short o=optimoptions('lsqnonlin','TolFun',100*eps); warning ('off','fininst:hwcalbycapfloor:NoConverge') [Alpha, Sigma, OptimOut] = hwcalbycap(RateSpec, MarketStrike, MarketMat,... MarketVol, Strike, Settle, Maturity, 'Reset', Reset, 'Principal', Principal,... 'Basis', Basis, 'OptimOptions', o, 'model', 'normal')```
```Local minimum possible. lsqnonlin stopped because the size of the current step is less than the value of the step size tolerance. ```
```Alpha = 1.0000e-06 ```
```Sigma = 0.3384 ```
```OptimOut = struct with fields: resnorm: 1.5181e-04 residual: [5x1 double] exitflag: 2 output: [1x1 struct] lambda: [1x1 struct] jacobian: [5x2 double] ```

The `OptimOut.residual` field of the `OptimOut` structure is the optimization residual. This value contains the difference between the Normal (Bachelier) caplets and those calculated during the optimization. Use the `OptimOut.residual` value to calculate the percentual difference (error) compared to Normal (Bachelier) caplet prices, and then decide whether the residual is acceptable. There is almost always some residual, so decide if it is acceptable to parameterize the market with a single value of `Alpha` and `Sigma`.

Price the caplets using the market data and Normal (Bachelier) model to obtain the reference caplet values. To determine the effectiveness of the optimization, calculate reference caplet values using the Normal (Bachelier) formula and the market data. Note, you must first interpolate the market data to obtain the caplets for calculation.

```MarketMatNum = datenum(MarketMat); [Mats, Strikes] = meshgrid(MarketMatNum, MarketStrike); FlatVol = interp2(Mats, Strikes, MarketVol, datenum(Maturity), Strike, 'spline'); [CapPrice, Caplets] = capbynormal(RateSpec, Strike, Settle, Maturity, FlatVol,... 'Reset', Reset, 'Basis', Basis, 'Principal', Principal); Caplets = Caplets(2:end)'```
```Caplets = 5×1 4.7392 6.7799 8.2609 9.6136 10.6455 ```

Compare the optimized values and Normal (Bachelier) values, and display the results graphically. After calculating the reference values for the caplets, compare the values analytically and graphically to determine whether the calculated single values of `Alpha` and `Sigma` provide an adequate approximation.

```OptimCaplets = Caplets+OptimOut.residual; disp(' ');```
``` ```
`disp(' Bachelier Calibrated Caplets');`
``` Bachelier Calibrated Caplets ```
`disp([Caplets OptimCaplets])`
``` 4.7392 4.7453 6.7799 6.7851 8.2609 8.2657 9.6136 9.6112 10.6455 10.6379 ```
```plot(MarketMatNum(2:end), Caplets, 'or', MarketMatNum(2:end), OptimCaplets, '*b'); datetick('x', 2) xlabel('Caplet Maturity'); ylabel('Caplet Price'); ylim ([0 16]); title('Bachelier and Calibrated Caplets'); h = legend('Bachelier Caplets', 'Calibrated Caplets'); set(h, 'color', [0.9 0.9 0.9]); set(h, 'Location', 'SouthEast'); set(gcf, 'NumberTitle', 'off') grid on``` 