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

VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2018,5,1),'Strike',29,'OptionType',"put",'ExerciseStyle',"european",'Name',"vanilla_option")

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

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

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

Settle = datetime(2018,1,1);
Maturity = datetime(2019,1,1);
Rate = 0.05;
myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)

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

NumPeriods = 15;
LRPricer = finpricer("AssetTree",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',50,'PricingMethod',"LeisenReimer",'Maturity',datetime(2018,5,1),'NumPeriods',NumPeriods)
LRPricer.Tree

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

[Price, outPR] = price(LRPricer,VanillaOpt,["all"])
outPR.Results
outPR.PricerData.PriceTree
outPR.PricerData.PriceTree.ExTree

% Copyright 2020 The MathWorks, Inc.