%% Price Double Barrier Instrument Using Black-Scholes Model and Vanna Volga Pricer
% This example shows the workflow to price a DoubleBarrier instrument when you use a BlackScholes model and a VannaVolga pricing method.
%% Create DoubleBarrier Instrument Object
% Use fininstrument to create a DoubleBarrier instrument object.

DoubleBarrierOpt = fininstrument("DoubleBarrier",'Strike',100,'ExerciseDate',datetime(2020,8,15),'OptionType',"call",'ExerciseStyle',"European",'BarrierType',"DKO",'BarrierValue',[110 80],'Name',"doublebarrier_option")

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

BlackScholesModel = finmodel("BlackScholes","Volatility",0.02)

%% Create ratecurve Object
% Create a flat ratecurve object using ratecurve.

Settle = datetime(2019,9,15);
Maturity = datetime(2023,9,15);
Rate = 0.035;
myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)

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

VolRR = -0.0045;
VolBF = 0.0037;
RateF = 0.0210;
outPricer = finpricer("VannaVolga","DiscountCurve",myRC,"Model",BlackScholesModel,'SpotPrice',100,'DividendValue',RateF,'VolatilityRR',VolRR,'VolatilityBF',VolBF)

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

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

% Copyright 2020 The MathWorks, Inc.