%% Use a Roll-Geske-Whaley Pricer and Black-Scholes Model to Price Vanilla Instrument
% This example shows the workflow to price an American exercise Vanilla instrument when you use a BlackScholes model and a RollGeskeWhaley pricing method.
%% Create Vanilla Instrument Object
% Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2022,9,15),'Strike',105,'ExerciseStyle',"american",'Name',"vanilla_american_instrument")

%
%% Create BlackScholes Model Object
% Use finmodel to create a BlackScholes model object.

BlackScholesModel = finmodel("BlackScholes",'Volatility',0.07)

%% Create ratecurve Object
% Create a flat ratecurve object using ratecurve.

Settle = datetime(2018,9,15);
myRC = ratecurve("zero",Settle,datetime(2023,9,15),.05,'Basis',12);

%% Create RollGeskeWhaley Pricer Object
% Use finpricer to create a RollGeskeWhaley pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100,"DividendValue",timetable(datetime(2021,6,15),0.25),'PricingMethod',"RollGeskeWhaley")

%% Price Vanilla Instrument
% Use price to compute the price and sensitivities for the Vanilla instrument.

[Price, outPR] = price(outPricer,VanillaOpt,["all"])
outPR.Results

%
% Copyright 2019 The MathWorks, Inc.