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

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

% Copyright 2015 The MathWorks, Inc.


%% 
% Define the OIS and Libor curves. 
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 swaption instruments.
ExerciseDate = '15-Mar-2018';
Maturity = {'15-Mar-2020';'15-Mar-2023'};
OptSpec = 'call';
Strike = 0.04;
BlackVol = 0.2;
%% 
% Price the swaption instruments using the term structure |OISCurve| both for discounting
% the cash flows and generating the future forward rates. 
Price = swaptionbyblk(OISCurve, OptSpec, Strike, Settle, ExerciseDate, Maturity, BlackVol,'Reset',1)
%%
% Price the swaption instruments using the term structure |LiborCurve| to generate 
% the future forward rates. The term structure |OISCurve| is used for discounting
% the cash flows.
PriceLC = swaptionbyblk(OISCurve, OptSpec, Strike, Settle, ExerciseDate, Maturity, BlackVol,'ProjectionCurve',LiborCurve,'Reset',1)