%% Create Zero Curve Using DiscountCurve Input
% This example shows how to create a ratecurve object using irbootstrap with Deposit and Swap instruments and a DiscountCurve for discounting cash flows.

Settle = datetime(2021,4,15); 
crvDates = Settle + [calmonths([1 2 3 6]) calyears([1 2 3 5 7 10 20 30])]';
crvRates = [0.0004 0.0004 0.0005 0.0006 0.0008 0.0018 0.0037 0.0088 0.013 0.0165 0.022 0.0233]';
DiscountCurve = ratecurve("zero",Settle,crvDates,crvRates);

DepRates = [0.002 0.0021 0.0023 0.0024 .0028]';
DepDates = Settle + calmonths([1 2 3 6 12]');

SwapRates = [0.0041 0;0.0057 0;0.017 0;0.0193 0;0.024 0;0.027 0];
SwapTimes = [2 3 5 10 20 30]';
SwapDates = datemnth(Settle,12*SwapTimes);

BootInstruments = [fininstrument("deposit","Maturity",DepDates,"Rate",DepRates); ...
    fininstrument("swap","Maturity",SwapDates,"LegRate",SwapRates)];

ZeroCurve = irbootstrap(BootInstruments,Settle,'DiscountCurve',DiscountCurve)

% Copyright 2021 The MathWorks, Inc.