## Valuing an Existing CDS Contract

The current value, or mark-to-market, of an existing CDS contract is the amount of money the contract holder would receive (if positive) or pay (if negative) to unwind this contract. The upfront of the contract is the current value expressed as a fraction of the notional amount of the contract, and it is commonly used to quote market values.

The value of existing CDS contracts is obtained with cdsprice. By default, cdsprice treats contracts as long positions. Whether a contract position is long or short is determined from a protection standpoint, that is, long means that protection was bought, and short means protection was sold. In the following example, an existing CDS contract pays a premium that is lower than current market conditions. The price is positive, as expected, since it would be more costly to buy the same type of protection today.

Settle = '17-Jul-2009';   % valuation date for the CDS
MarketDates = datenum({'20-Sep-10','20-Sep-11','20-Sep-12','20-Sep-14',...
'20-Sep-16'});
MarketSpreads = [140 175 210 265 310]';

ZeroDates = datenum({'17-Jan-10','17-Jul-10','17-Jul-11','17-Jul-12',...
'17-Jul-13','17-Jul-14'});
ZeroRates = [1.35 1.43 1.9 2.47 2.936 3.311]'/100;
ZeroData = [ZeroDates ZeroRates];

[ProbData,HazData] = cdsbootstrap(ZeroData,MarketData,Settle);

Maturity2 = '20-Sep-2012';

[Price,AccPrem,PaymentDates,PaymentTimes,PaymentCF] = cdsprice(ZeroData,...

fprintf('Dirty Price: %8.2f\n',Price+AccPrem);
fprintf('Clean Price: %8.2f\n',Price);
fprintf('\nPayment Schedule:\n\n');
fprintf('Date \t\t Time Frac \t Amount\n');
for k = 1:length(PaymentDates)
fprintf('%s \t %5.4f \t %8.2f\n',datestr(PaymentDates(k)),...
PaymentTimes(k),PaymentCF(k));
end

This resulting payment schedule is:

Dirty Price: 56872.94
Clean Price: 41628.50

Payment Schedule:

Date 		 Time Frac 	 Amount
20-Sep-2009 	 0.1806 	 35388.89
20-Dec-2009 	 0.2528 	 49544.44
20-Mar-2010 	 0.2500 	 49000.00
20-Jun-2010 	 0.2556 	 50088.89
20-Sep-2010 	 0.2556 	 50088.89
20-Dec-2010 	 0.2528 	 49544.44
20-Mar-2011 	 0.2500 	 49000.00
20-Jun-2011 	 0.2556 	 50088.89
20-Sep-2011 	 0.2556 	 50088.89
20-Dec-2011 	 0.2528 	 49544.44
20-Mar-2012 	 0.2528 	 49544.44
20-Jun-2012 	 0.2556 	 50088.89
20-Sep-2012 	 0.2556 	 50088.89

Also, you can use cdsprice to value a portfolio of CDS contracts. In the following example, a simple hedged position with two vanilla CDS contracts, one long, one short, with slightly different spreads is priced in a single call and the value of the portfolio is the sum of the returned prices:

[Price2,AccPrem2] = cdsprice(ZeroData,ProbData,Settle,...
'Notional',[1e7; -1e7]);

fprintf('Contract \t Dirty Price \t Acc Premium \t  Clean Price\n');
fprintf('    Long \t \$ %9.2f \t \$ %9.2f \t \$ %9.2f \t\n',...
Price2(1)+AccPrem2(1), AccPrem2(1), Price2(1));
fprintf('   Short \t \$ %8.2f \t \$ %8.2f \t \$ %8.2f \t\n',...
Price2(2)+AccPrem2(2), AccPrem2(2), Price2(2));
fprintf('Mark-to-market of hedged position: \$ %8.2f\n',sum(Price2)+sum(AccPrem2));

This resulting value of the portfolio is:

Contract 	 Dirty Price 	 Acc Premium 	  Clean Price
Long 	 \$  56872.94 	 \$  15244.44 	 \$  41628.50
Short 	 \$ -48185.88 	 \$ -15477.78 	 \$ -32708.11
Mark-to-market of hedged position: \$  8687.06