%% Calculate Price and Sensitivities for an American Double Knock-Out Call Option with Rebate
% Compute the price and sensitivities for an American double barrier option for a double knock-out (down and out-up and out) call option with a rebate 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.

LBarrier = 80; 
UBarrier = 130; 
Barrier = [UBarrier LBarrier];
BarrierSpec = 'DKO';
OptSpec = 'Call';
Strike = 110;
Rebate = 1;
OutSpec = {'price'; 'vega'; 'theta'};

%
% Compute the price and sensitivities for an American option using finite differences.

[Price, Vega, Theta] = dblbarriersensbyfd(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, BarrierSpec, Barrier,'Rebate', Rebate, 'AmericanOpt', 1,'Outspec', OutSpec)

% Copyright 2018 The MathWorks, Inc.