%% Price Double Touch Instrument Using a Black-Scholes Model and Asset Monte Carlo Pricer
% This example shows the workflow to price a DoubleTouch instrument when you use a BlackScholes model and an AssetMonteCarlo pricing method.
%% Create DoubleTouch Instrument Object
% Use fininstrument to create a DoubleTouch instrument object.

DoubleTouchOpt = fininstrument("DoubleTouch",'ExerciseDate',datetime(2022,9,15),'BarrierValue',[110 90],'PayoffValue',50,'BarrierType',"DOT",'Name',"doubletouch_option")

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

BlackScholesModel = finmodel("BlackScholes",'Volatility',.2)

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

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

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

% Copyright 2020 The MathWorks, Inc.