%% Bootstrap ratecurve Object from Market Data
%% Define Deposit and Swap Parameters

Settle = datetime(2018,3,21);
DepRates = [.0050769 .0054934 .0061432 .0072388 .0093263]';
DepTimes = [1 2 3 6 12]';
DepDates = datemnth(Settle,DepTimes);
nDeposits = length(DepTimes);
 
SwapRates = [.0112597 0;.0128489 0;.0138917 0;.0146135 0;.0151175 0;...
      .0155184 0;.0158536 0;.0161435 0];
SwapTimes = (2:9)';
SwapDates = datemnth(Settle,12*SwapTimes);
nSwaps = length(SwapTimes);
 
nInst = nDeposits + nSwaps;

%% Create a Vector of Market Swap Instruments
% Use fininstrument to create a vector of market Deposit and Swap instrument objects.

 BootInstruments(nInst,1) = fininstrument.FinInstrument;
 for ii=1:length(DepDates)
      BootInstruments(ii) = fininstrument("deposit",'Maturity',DepDates(ii),'Rate',DepRates(ii));
 end
 
 for ii=1:length(SwapDates)
      BootInstruments(ii+nDeposits) = fininstrument("swap",'Maturity',SwapDates(ii),'LegRate',[SwapRates(ii) 0]);
 end

%% Create ratecurve Object for Zero-Rate Curve
% Use irbootstrap to create a ratecurve object for the zero-rate curve.

ZeroCurve = irbootstrap(BootInstruments,Settle)

% Copyright 2019 The MathWorks, Inc.