%% Price Multiple Spread Instruments with European Option Using Black-Scholes Model and Bjerksund-Stensland Pricer
% This example shows the workflow to price multiple Spread instruments with a European option when using a BlackScholes model and a BjerksundStensland pricing method.
%% Create Spread Instrument Object
% Use fininstrument to create a Spread instrument object for three Spread instruments.

SpreadOpt = fininstrument("Spread",'Strike',[105 ; 120 ; 150],'ExerciseDate',datetime([2021,9,15 ; 2021,10,15 ; 2021,11,15]),'OptionType',"put",'ExerciseStyle',"european",'Name',"spread_option")

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

BlackScholesModel = finmodel("BlackScholes",'Volatility',[0.2,0.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 BjerksundStensland Pricer Object
% Use finpricer to create a BjerksundStensland pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',[103 160],'DividendValue',[0.025 , 0.028],'PricingMethod',"BjerksundStensland")

%% Price Spread Instruments
% Use price to compute the prices and sensitivities for the Spread instruments.

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

% Copyright 2021 The MathWorks, Inc.