%% Calculate the Price and Sensitivities for a One-Touch Option
% Compute the price and sensitivities for a one-touch option using the following data:

AssetPrice = 105;
Rate = 0.1;
Volatility = 0.2;
Settle = '01-Jan-2018';
Maturity = '01-Jul-2018';

%
% Define the RateSpec using intenvset.

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

%
% Define the StockSpec using StockSpec.

DividendType = "Continuous";
DividendYield = Rate - 0.1;
StockSpec = stockspec(Volatility, AssetPrice, DividendType, DividendYield);

% Define the sensitivities.

OutSpec = {'price', 'delta', 'gamma'};

% Calculate the price and sensitivities for a one-touch binary option.

BarrierSpec = "OT";
Barrier = 100;
Payoff = 15;
 
[Price, Delta, Gamma] = touchsensbybls(RateSpec, StockSpec, Settle, Maturity, BarrierSpec, Barrier, Payoff,'OutSpec',OutSpec)

% Copyright 2019 The MathWorks, Inc.