%% Calculate Price and Sensitivities for a European Double Knock-Out Call Option
% Compute the price and sensitivities for a European double knock-out (down and out-up and out) call option using the following data:

Rate = 0.05;
Settle = '01-Jun-2018';
Maturity = '01-Dec-2018';
Basis = 1;

%
% Define a RateSpec.

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

%
% Define a StockSpec.

AssetPrice = 100; 
Volatility = 0.25;
StockSpec = stockspec(Volatility, AssetPrice);

% Define the double barrier option and sensitivities.

LBarrier = 80; 
UBarrier = 130; 
Barrier = [UBarrier LBarrier];
BarrierSpec = 'DKO';
OptSpec = 'Call';
Strike = 110;
OutSpec = {'Price', 'Delta', 'Gamma'};

%
% Compute the price of the option using flat boundaries.

[PriceFlat, Delta, Gamma] = dblbarriersensbybls(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, BarrierSpec, Barrier,'OutSpec', OutSpec)

% Compute the price of the option using two curved boundaries.

Curvature = [0.05 -0.05];
[PriceCurved, Delta, Gamma] = dblbarriersensbybls(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, BarrierSpec, Barrier, 'Curvature', Curvature,'OutSpec', OutSpec)

%
% Copyright 2018 The MathWorks, Inc.