%% Compute the Price and Sensitivities of a Vanilla Option
% Define the RateSpec.

StartDates = 'Jan-1-2013';
EndDates = 'Jan-1-2015';
Rates = 0.05;
RateSpec = intenvset('ValuationDate', StartDates, 'StartDates', StartDates, ...
'EndDates', EndDates, 'Rates', Rates)

%
% Define the StockSpec for the asset.

AssetPrice = 100;
Sigma = 0.1;
DivType = 'continuous';
DivAmounts = 0.04;
StockSpec = stockspec(Sigma, AssetPrice, DivType, DivAmounts)

%
% Define the vanilla option.

OptSpec = 'call';  
Settle = 'jan-1-2013';
ExerciseDates = 'jan-1-2015';
Strike = 105;

%
% Compute the Delta sensitivity for the vanilla option using the Longstaff-Schwartz model.

Antithetic = true;
OutSpec = {'Delta'};
PriceSens = optstocksensbyls(RateSpec, StockSpec, OptSpec, Strike, ...
Settle, ExerciseDates,'Antithetic', Antithetic, 'OutSpec', OutSpec)

%
% To display the output for Price, Delta, Path, and Times, use the following:

OutSpec = {'Price','Delta'};
[Price, Delta, Path, Times] = optstocksensbyls(RateSpec, StockSpec, OptSpec, Strike, ...
Settle, ExerciseDates,'Antithetic', Antithetic, 'OutSpec', OutSpec);

% Copyright 2015 The MathWorks, Inc.