%% Use Heynen-Kat Pricer and Black-Scholes Model to Price Partial Lookback Instrument
% This example shows the workflow to price a PartialLookback instrument when you use a BlackScholes model and a HeynenKat pricing method.
%% Create PartialLookback Instrument Object
% Use fininstrument to create an PartialLookback instrument object.

PartialLookbackOpt = fininstrument("PartialLookback",'ExerciseDate',datetime(2022,9,15),'Strike',100,'MonitorDate',datetime(2021,9,15),'OptionType',"put",'ExerciseStyle',"european",'Name',"partial_lookback_option")

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

BlackScholesModel = finmodel("BlackScholes",'Volatility',0.32)

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

outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100,'DividendType',"continuous",'DividendValue',.05,'PricingMethod',"HeynenKat")

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

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

% Copyright 2021 The MathWorks, Inc.