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

VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime([2018,5,1 ; 2018,6,1 ; 2018,7,1]),'Strike',[29 ; 38 ; 70],'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 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',30,'DividendValue',0.045)

%% Price Vanilla Instruments
% Use price to compute the prices and sensitivities for the Vanilla instruments.

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

% Copyright 2021 The MathWorks, Inc.