%% Calculate the Sensitivity Values for an Interest-Rate Swaption with Normal (Bachelier) Implied Volatility
% This example shows how to use optsensbysabr to calculate sensitivities for an interest-rate swaption using the Normal model for the case where the Beta parameter is > 0 and where Beta = 0.
% For the case where the Beta parameter is > 0, select the Normal (Bachelier) implied volatility model in optsensbysabr, specify the 'Model' name-value pair to 'normal'.

% Define the interest rate and the model parameters.

SwapRate = 0.025;
Strike = 0.02;
Alpha = 0.044;
Beta = 0.5;
Rho = -0.21;
Nu = 0.31;
Rates = 0.028;

% Define the Settle, ExerciseDate, and OptSpec for the swaption.

Settle = datenum('7-Mar-2018');
ExerciseDate = datenum('7-Mar-2020');
OptSpec = 'call';

% Define the RateSpec for the interest-rate curve.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
    'EndDates', ExerciseDate, 'Rates', Rates, 'Compounding', -1, 'Basis', 1);

% Calculate the Delta and Vega sensitivity values for the swaption. Set the
% 'Model' name-value pair to 'normal' in order to select the Normal
% (Bachelier) implied volatility model.

[SABRDelta, SABRVega] = optsensbysabr(RateSpec, Alpha, Beta, Rho, Nu, ...
    Settle, ExerciseDate, SwapRate, Strike, OptSpec, ...
    'OutSpec',  {'Delta', 'Vega'}, 'Model', 'normal')

%
%% Calculate Sensitivities for a Swaption with Normal Implied Volatility Using the Normal SABR Model
% When the Beta parameter is set to zero, the SABR model becomes the Normal SABR model. Negative interest rates are allowed when the Normal SABR model is used in combination with Normal (Bachelier) implied volatility. To select the Normal (Bachelier) implied volatility model in optsensbysabr, specify the 'Model' name-value pair to 'normal'.

% Define the interest rate and the model parameters. 

SwapRate = -0.00254;
Strike = -0.002;
Alpha = 0.0047;
Beta = 0;  % Set the Beta parameter to zero to use the Normal SABR model
Rho = -0.20;
Nu = 0.28;
Rates = 0.0001;

% Define the Settle, ExerciseDate, and OptSpec for the swaption.

Settle = datenum('11-Apr-2018');
ExerciseDate = datenum('11-Apr-2019');
OptSpec = 'call';

% Define the RateSpec for the interest-rate curve.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
    'EndDates', ExerciseDate, 'Rates', Rates, 'Compounding', -1, 'Basis', 1);

% Calculate the Delta and Vega sensitivity values for the swaption. Set the
% 'Model' name-value pair to 'normal' in order to select the Normal
% (Bachelier) implied volatility model.

[SABRDelta, SABRVega] = optsensbysabr(RateSpec, Alpha, Beta, Rho, Nu, ...
    Settle, ExerciseDate, SwapRate, Strike, OptSpec, ...
    'OutSpec',  {'Delta', 'Vega'}, 'Model', 'normal')

% Copyright 2012 The MathWorks, Inc.