%% Price Lookback Instrument Using a Bates Model and Asset Monte-Carlo Pricer
% This example shows the workflow to price a LookBack instrument when you use a Bates model and an AssetMonetCarlo pricing method.
%% Create Lookback Instrument Object
% Use fininstrument to create a Lookback instrument object.

LookbackOpt = fininstrument("Lookback",'Strike',105,'ExerciseDate',datetime(2022,9,15),'OptionType',"put",'ExerciseStyle',"european",'Name',"lookback_option")

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

BatesModel = finmodel("Bates",'V0',0.032,'ThetaV',0.1,'Kappa',0.003,'SigmaV',0.2,'RhoSV',0.9,'MeanJ',0.11,'JumpVol',.023,'JumpFreq',0.02)

%% 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",BatesModel,'SpotPrice',100,'simulationDates',datetime(2022,9,15))

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

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

% Copyright 2020 The MathWorks, Inc.