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

AsianOpt = fininstrument("Asian",'ExerciseDate',datetime(2022,9,15),'Strike',105,'OptionType',"put",'ExerciseStyle',"european",'Name',"asian_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 Levy Pricer Object
% Use finpricer to create a Levy pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100,'PricingMethod',"Levy")

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

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

% Copyright 2019 The MathWorks, Inc.