www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceaCapUsingBlacksModelWithTwoCurvesExample.m

    %% Price a Cap Using a Different Curve to Generate the Future Forward Rates 

% Copyright 2015 The MathWorks, Inc.


%% 
% Define the OIS and Libor rates. 
Settle = datenum('15-Mar-2013');
CurveDates = daysadd(Settle,360*[1/12 2/12 3/12 6/12 1 2 3 4 5 7 10],1);
OISRates = [.0018 .0019 .0021 .0023 .0031 .006  .011 .017 .021 .026 .03]';
LiborRates = [.0045 .0047 .005 .0055 .0075 .0109  .0162 .0216 .0262 .0309 .0348]';  

%% 
% Create an associated |RateSpec| for the OIS and Libor curves. 
OISCurve = intenvset('Rates',OISRates,'StartDate',Settle,'EndDates',CurveDates,'Compounding',2,'Basis',1);
LiborCurve = intenvset('Rates',LiborRates,'StartDate',Settle,'EndDates',CurveDates,'Compounding',2,'Basis',1);  
%%
% Define the Cap instruments.
Maturity = {'15-Mar-2018';'15-Mar-2020'};
Strike = [0.04;0.05];
BlackVol = 0.2;
%% 
% Price the cap instruments using the term structure |OISCurve| both for discounting
% the cash flows and generating future forward rates. 
[Price, Caplets] = capbyblk(OISCurve, Strike, Settle, Maturity, BlackVol)
%%
% Price the cap instruments using the term structure |LiborCurve| to generate 
% future forward rates. The term structure |OISCurve| is used for discounting
% the cash flows.
[PriceLC, CapletsLC] = capbyblk(OISCurve, Strike, Settle, Maturity, BlackVol,'ProjectionCurve',LiborCurve)