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

    %% Price a European Swaption Using the Black Model Where the Yield Curve is Flat at 6%  
% Price a European swaption that gives the holder the right to enter in
% five years into a three-year paying swap where a fixed-rate of 6.2% is
% paid and floating is received. Assume that the yield curve is flat at
% 6% per annum with continuous compounding, the volatility of the swap rate
% is 20%, the principal is $100, and payments are exchanged semiannually.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Create the |RateSpec|. 
Rate = 0.06;
Compounding  = -1;
ValuationDate = 'Jan-1-2010';
EndDates =   'Jan-1-2020'; 
Basis = 1; 

RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', ValuationDate, ...
'EndDates', EndDates, 'Rates', Rate, 'Compounding', Compounding, 'Basis', Basis);  

%% 
% Price the swaption using the Black model. 
Settle = 'Jan-1-2011';
ExerciseDates = 'Jan-1-2016';
Maturity = 'Jan-1-2019'; 
Reset = 2; 
Principal = 100;
Strike = 0.062;
Volatility = 0.2;
OptSpec = 'call';

Price= swaptionbyblk(RateSpec, OptSpec, Strike, Settle, ExerciseDates, Maturity, ...
Volatility, 'Reset', Reset, 'Principal', Principal, 'Basis', Basis)