%% Compute Par Yield Curve Given a Zero Curve and Maturity Dates Using datetime Inputs
% Given a zero curve over a set of maturity dates, a settlement date, and annual compounding for the input zero curve and monthly compounding for the output par rates, use datetime inputs to compute a par yield curve.

ZeroRates = [0.0457
0.0487
0.0506
0.0507
0.0505
0.0504
0.0506
0.0516
0.0539
0.0530];
CurveDates = [datenum('06-Nov-2000')
datenum('11-Dec-2000')
datenum('15-Jan-2001')
datenum('05-Feb-2001')
datenum('04-Mar-2001')
datenum('02-Apr-2001')
datenum('30-Apr-2001')
datenum('25-Jun-2001')
datenum('04-Sep-2001')
datenum('12-Nov-2001')];
Settle = datenum('03-Nov-2000');
InputCompounding = 12;
InputBasis = 2;
OutputCompounding = 1;
OutputBasis = 2;

CurveDates = datetime(CurveDates, 'ConvertFrom', 'datenum','Locale','en_US');
Settle = datetime(Settle,'ConvertFrom','datenum','Locale','en_US');
[ParRates, CurveDates] = zero2pyld(ZeroRates, CurveDates,...
Settle, 'InputCompounding',12,'InputBasis',2,'OutputCompounding',1,'OutputBasis',2)

% Copyright 2012 The MathWorks, Inc.