%% Use the bootstrap Method to Create an IRDataCurve Object That Includes Bonds
% In this bootstrapping example, InstrumentTypes, Instruments, and a Settle date are defined:

CurveSettle = datenum('8-Mar-2010');

InstrumentTypes = {'Deposit';'Deposit';'Deposit';'Deposit';...
    'Futures';'Futures';'Futures';'Futures';'Swap';'Swap';'Bond';'Bond'};

Instruments = [datenum('8-Mar-2010'),datenum('8-Apr-2010'),.003; ...
    datenum('8-Mar-2010'),datenum('8-Jun-2010'),.005; ...
    datenum('8-Mar-2010'),datenum('8-Sep-2010'),.007; ...
    datenum('8-Mar-2010'),datenum('8-Mar-2011'),.009; ...
    datenum('8-Mar-2010'),datenum('18-Jun-2011'),9840; ...
    datenum('8-Mar-2010'),datenum('17-Sep-2011'),9820; ...
    datenum('8-Mar-2010'),datenum('17-Dec-2011'),9810; ...
    datenum('8-Mar-2010'),datenum('18-Mar-2012'),9800; ...
    datenum('8-Mar-2010'),datenum('8-Mar-2015'),.025; ...
    datenum('8-Mar-2010'),datenum('8-Mar-2020'),.035; ...
    datenum('8-Mar-2010'),datenum('8-Mar-2030'),99; ...
    datenum('8-Mar-2010'),datenum('8-Mar-2040'),101];

%
% When bonds are used, InstrumentCouponRate must be specified:

InstrumentCouponRate = [zeros(10,1);.045;.05];

% Note, for parameters that are only applicable to bonds (InstrumentFirstCouponDate, InstrumentLastCouponDate, InstrumentIssueDate, InstrumentFace) the entries for non-bond instruments (deposits and futures) are ignored.
%
% Use the bootstrap method to create an IRDataCurve object.

bootModel = IRDataCurve.bootstrap('Forward', CurveSettle, ...
InstrumentTypes, Instruments,'InterpMethod','pchip',...
'InstrumentCouponRate',InstrumentCouponRate);

%
% Create the plot for the bootstrapped market data.

PlottingDates = datemnth(CurveSettle,1:30*12);
plot(PlottingDates, getParYields(bootModel, PlottingDates),'r')
ylim([0 .06])
datetick

% Copyright 2012 The MathWorks, Inc.