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

TouchOpt = fininstrument("Touch",'ExerciseDate',datetime(2022,9,15),'BarrierValue',140,'PayoffValue',170,'BarrierType',"OT",'Name',"touch_option")

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

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

%% 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 BlackScholes Pricer Object
% Use finpricer to create a BlackScholes 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.045)

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

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

% Copyright 2020 The MathWorks, Inc.