%% Compute Spread Over a Yield Curve for a Cash Flow
% Use cfspread to compute the spread over a yield curve for a cash flow.
% Define data for the yield curve.

Settle = datenum('01-Jul-2003');
CurveDates = daysadd(Settle,360*[.25 .5 1 2 3 5 7 10 20],1);
ZeroRates = [.0089 .0096 .0107 .0130 .0166 .0248 .0306 .0356 .0454]';

%
% Compute the RateSpec.

RateSpec = intenvset('StartDates', Settle, 'EndDates', CurveDates,...
'Rates', ZeroRates)

%
% Compute the spread.

Price = 98;
CFAmounts = [30;40;30];
CFDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'});

Spread = cfspread(RateSpec, Price, CFAmounts, CFDates, Settle)

% Copyright 2015 The MathWorks, Inc.