%% Price Bermudan Option for Vanilla Instrument Using Black-Scholes Model and Finite Difference Pricer
% This example shows the workflow to price a Bermudan option for a Vanilla instrument when you use a BlackScholes model and a FiniteDifference pricing method.
%% Create Vanilla Instrument Object
% Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",'Strike',[110,120],'ExerciseDate',[datetime(2022,9,15) , datetime(2023,9,15)],'OptionType',"call",'ExerciseStyle',"Bermudan",'Name',"vanilla_option")

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

BlackScholesModel = finmodel("BlackScholes","Volatility",0.2)

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

Settle = datetime(2018,9,15);
Maturity = datetime(2023,9,15);
Rate = 0.035;
myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)

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

outPricer = finpricer("FiniteDifference",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100)

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

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

% Copyright 2020 The MathWorks, Inc.