%% Stripping Caplet Volatilities Using Manually Specified Caplet Dates
% Compute the zero curve for discounting and projecting forward rates.

ValuationDate = datenum('06-Mar-2015');
ZeroRates = [0.01 0.08 0.27 0.73 1.16 1.70]/100;
CurveDates = datemnth(ValuationDate, [0.25 0.5 1 2 3 5]*12);
ZeroCurve = IRDataCurve('Zero',ValuationDate,CurveDates,ZeroRates)

%
% Define the cap volatility data.

CapSettle = datenum('06-Mar-2015');
CapMaturity = datenum({'07-Mar-2016';'06-Mar-2017';'06-Mar-2018'; ...
    '06-Mar-2019';'06-Mar-2020'});
CapVolatility = [0.43;0.44;0.44;0.43;0.41];
CapStrike = 0.011;

%
% Specify quarterly and semiannual dates.

CapletDates = [cfdates(CapSettle, '06-Mar-2016', 4) ...
     cfdates('06-Mar-2016', '06-Mar-2020', 2)]';
CapletDates(~isbusday(CapletDates)) =  ...
    busdate(CapletDates(~isbusday(CapletDates)), 'modifiedfollow');

%
% Strip caplet volatilities using specified CapletDates.

[CapletVols, CapletPaymentDates, CapStrikes] = capvolstrip(ZeroCurve, ...
    CapSettle, CapMaturity, CapVolatility, 'Strike', CapStrike, ...
    'CapletDates', CapletDates);

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

% Copyright 2012 The MathWorks, Inc.