%% Use Goldman-Sosin-Gatto Pricer and Black-Scholes Model to Price Lookback Instrument
% This example shows the workflow to price a floating-strike Lookback instrument when you use a BlackScholes model and a GoldmanSosinGatto pricing method.
%% Create Lookback Instrument Object
% Use fininstrument to create a floating-strike Lookback instrument object where the Strike argument is specified as NaN.

LookbackOpt = fininstrument("lookback",'Strike',NaN,'ExerciseDate',datetime(2021,9,15),'OptionType',"put",'ExerciseStyle',"european",'Name',"lookback_option")

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

BlackScholesModel = finmodel("BlackScholes",'Volatility',.358)

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

outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100,'DividendValue',0.025,'DividendType',"continuous",'PricingMethod',"GoldmanSosinGatto")

%% Price Lookback Instrument
% Use price to compute the price and sensitivities for the floating-strike Lookback instrument.

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

%
% Copyright 2019 The MathWorks, Inc.