%% Stripping Floorlet Volatilities from Floors Using Normal Model
% Compute the zero curve for discounting and projecting forward rates.

ValuationDate = datenum('1-May-2018');
ZeroRates = [-0.31 -0.27 -0.18 -0.05 0.015 0.22]/100;
CurveDates = datemnth(ValuationDate, [0.25 0.5 1 2 3 5]*12);
ZeroCurve = IRDataCurve('Zero',ValuationDate,CurveDates,ZeroRates)

%
% Define the normal floor volatility data.

FloorSettle = datenum('1-May-2018');
FloorMaturity = datenum({'1-May-2019';'1-May-2020';'3-May-2021'; ...
    '2-May-2022';'1-May-2023'});
FloorVolatility = [0.0065;0.0067;0.0064;0.0058;0.0055]; % Normal volatilities
FloorStrike = -0.005; % -0.5 percent strike.

%
% Strip floorlet volatilities from floors using the Normal (Bachelier) model.

[FloorletVols, FloorletPaymentDates, FloorStrikes] = floorvolstrip(ZeroCurve, ...
    FloorSettle,FloorMaturity,FloorVolatility,'Strike',FloorStrike,'Model','normal');

PaymentDates = string(datestr(FloorletPaymentDates));
format;
table(PaymentDates,FloorletVols,FloorStrikes)

% Copyright 2018 The MathWorks, Inc.