www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PricingaSingleNameCDSOptionExample.m
%% Pricing a Single-Name CDS Option % This example shows how to price a single-name CDS option using |cdsoptprice|. % The function |cdsoptprice| is based on the Black's model as described % in O'Kane (2008). The optional |knockout| argument for |cdsoptprice| supports % two variations of the mechanics of a CDS option. CDS options can be knockout % or non-knockout options. % % * A knockout option cancels with no payments if there is a credit event % before the option expiry date. % * A non-knockout option does not cancel if there is a credit event before % the option expiry date. In this case, the option holder of a non-knockout % payer swaption can take delivery of the underlying long protection CDS % on the option expiry date and exercise the protection, delivering a defaulted % obligation in return for par. This portion of protection from option initiation % to option expiry is known as the front-end protection (FEP). While this distinction does not affect the receiver swaption, the price % of a non-knockout payer swaption is obtained by adding the value of the % FEP to the knockout payer swaption price. % Copyright 2015 The MathWorks, Inc. %% % Define the CDS instrument. Settle = datenum('12-Jun-2012'); OptionMaturity = datenum('20-Sep-2012'); CDSMaturity = datenum('20-Sep-2017'); OptionStrike = 200; SpreadVolatility = .4; %% % Define the zero rate. Zero_Time = [.5 1 2 3 4 5]'; Zero_Rate = [.5 .75 1.5 1.7 1.9 2.2]'/100; Zero_Dates = daysadd(Settle,360*Zero_Time,1); ZeroData = [Zero_Dates Zero_Rate] %% % Define the market data. Market_Time = [1 2 3 5 7 10]'; Market_Rate = [100 120 145 220 245 270]'; Market_Dates = daysadd(Settle,360*Market_Time,1); MarketData = [Market_Dates Market_Rate]; ProbData = cdsbootstrap(ZeroData, MarketData, Settle) %% % Define the CDS option. [Payer,Receiver] = cdsoptprice(ZeroData, ProbData, Settle, OptionMaturity, ... CDSMaturity, OptionStrike, SpreadVolatility, 'Knockout', true); fprintf(' Payer: %.0f Receiver: %.0f (Knockout)\n',Payer,Receiver); [Payer,Receiver] = cdsoptprice(ZeroData, ProbData, Settle, OptionMaturity, ... CDSMaturity, OptionStrike, SpreadVolatility, 'Knockout', false); fprintf(' Payer: %.0f Receiver: %.0f (Non-Knockout)\n',Payer,Receiver);