%% Stripping Caplet Volatilities from At-The-Money (ATM) Caps
% Compute the zero curve for discounting and projecting forward rates.

ValuationDate = datenum('23-Jun-2015');
ZeroRates = [0.01 0.09 0.30 0.70 1.07 1.71]/100;
CurveDates = datemnth(ValuationDate, [0.25 0.5 1 2 3 5]*12);
ZeroCurve = IRDataCurve('Zero',ValuationDate,CurveDates,ZeroRates)

%
% Define the ATM cap volatility data.

CapSettle = datenum('25-Jun-2015');
CapMaturity = datenum({'27-Jun-2016';'26-Jun-2017';'25-Jun-2018'; ...
    '25-Jun-2019';'25-Jun-2020'});
CapVolatility = [0.29;0.38;0.42;0.40;0.38];

%
% Strip caplet volatilities from ATM caps.

[CapletVols, CapletPaymentDates, ATMCapStrikes] = capvolstrip(ZeroCurve, ...
    CapSettle, CapMaturity, CapVolatility);

PaymentDates = cellstr(datestr(CapletPaymentDates));
format;
table(PaymentDates, CapletVols, ATMCapStrikes)

% Copyright 2012 The MathWorks, Inc.