%% Price Multiple Vanilla Floor Instruments Using Black Model and Black Pricer
% This example shows the workflow to price multiple vanilla Floor instruments when you use a Black model and a Black pricing method.
%% Create ratecurve Object
% Create a ratecurve object using ratecurve for the underlying interest-rate curve for the floor instrument.

Settle = datetime(2018,9,15);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
 
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)

%% Create Floor Instrument Object
% Use fininstrument to create a Floor instrument object for three Florr instruments.

FloorOpt = fininstrument("Floor",'Maturity',datetime([2022,9,15 ; 2022,9,15 ; 2022,9,15]),'Strike',[0.03 ; 0.04 ; 0.05],'ProjectionCurve',myRC)

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

BlackModel = finmodel("Black",'Volatility',0.2)

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

 outPricer = finpricer("analytic",'DiscountCurve',myRC,'Model',BlackModel)

%% Price Floor Instruments
% Use price to compute the prices for the Floor instruments.

[Price, outPR] = price(outPricer,FloorOpt)

% Copyright 2021 The MathWorks, Inc.