%% Price a Floor Using floorbynormal and Compare to floorbyblk
% Define the RateSpec.

Settle = datenum('20-Jan-2016');
ZeroTimes = [.5 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 = datemnth(Settle,12*ZeroTimes);
RateSpec = intenvset('StartDate',Settle,'EndDates',ZeroDates,'Rates',ZeroRates)

%
% Define the floor instrument and price with floorbyblk.

ExerciseDate = datenum('20-Jan-2026');

[~,ParSwapRate] = swapbyzero(RateSpec,[NaN 0],Settle,ExerciseDate)

Strike = .01;
BlackVol = .3;
NormalVol = BlackVol*ParSwapRate;

Price = floorbyblk(RateSpec,Strike,Settle,ExerciseDate,BlackVol)

%
% Price the floor instrument using floorbynormal.

Price_Normal = floorbynormal(RateSpec,Strike,Settle,ExerciseDate,NormalVol)

%
% Price the floor instrument using floorbynormal for a negative strike.

 Price_Normal = floorbynormal(RateSpec,-.005,Settle,ExerciseDate,NormalVol)

% Copyright 2012 The MathWorks, Inc.