%% Price Spread Instrument with American Option Using Black-Scholes Model and Asset Monte-Carlo Pricer
% This example shows the workflow to price a Spread instrument with an American option when using a BlackScholes model and an AssetMonteCarlo pricing method.
%% Create Spread Instrument Object
% Use fininstrument to create a Spread instrument object.

SpreadOpt = fininstrument("Spread",'Strike',100,'ExerciseDate',datetime(2021,9,15),'OptionType',"put",'ExerciseStyle',"American",'Name',"spread_option")

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

Corr = 0.42;
BlackScholesModel = finmodel("BlackScholes","Volatility",[0.3,0.1],"Correlation", [1 Corr;Corr 1])

%% 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 AssetMonteCarlo Pricer Object
% Use finpricer to create an AssetMonteCarlo pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("AssetMonteCarlo","DiscountCurve",myRC,"Model",BlackScholesModel,'SpotPrice',[100,95],'simulationDates',datetime(2021,9,15),'dividendType',["continuous","continuous"],'dividendvalue',[0,0.01])

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

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

% Copyright 2020 The MathWorks, Inc.