%% Determine the Spread of a Credit Default Swap
% This example shows how to use cdsspread to compute the spread (in basis points) for a CDS contract with the following data.

Settle = '17-Jul-2009'; % valuation date for the CDS
Zero_Time = [.5 1 2 3 4 5]';
Zero_Rate = [1.35 1.43 1.9 2.47 2.936 3.311]'/100;
Zero_Dates = daysadd(Settle,360*Zero_Time,1);
ZeroData = [Zero_Dates Zero_Rate];
ProbData = [daysadd(datenum(Settle),360,1), 0.0247];
Maturity = '20-Sep-2010';

Spread = cdsspread(ZeroData,ProbData,Settle,Maturity)

% Copyright 2012 The MathWorks, Inc.