%% Price Multiple Cliquet Instruments Using Black-Scholes Model and Rubinstein Pricer
% This example shows the workflow to price multiple Cliquet instruments when you use a BlackScholes model and a Rubinstein pricing method.
%% 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 Cliquet Instrument Object
% Use fininstrument to create a Cliquet instrument object for three Cliquet instruments.

ResetDates = Settle + years(0:0.25:1);  
CliquetOpt = fininstrument("Cliquet",'ResetDates',ResetDates,'InitialStrike',[140;150;160],'ExerciseStyle',"european",'Name',"cliquet_option")

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

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

%% Create Rubinstein Pricer Object
% Use finpricer to create a Rubinstein pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("analytic",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',135,'DividendValue',0.025,'PricingMethod',"Rubinstein")

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

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

% Copyright 2021 The MathWorks, Inc.