www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceaEuropeanSwaptionBlackModelWheretheYieldCurExample.m
%% Price a European Swaption Using the Black Model Where the Yield Curve Is Incrementally Increasing % Price a European swaption that gives the holder the right to enter into % a 5-year receiving swap in a year, where a fixed rate of 3% is received % and floating is paid. Assume that the 1-year, 2-year, 3-year, 4-year and % 5- year zero rates are 3%, 3.4%, 3.7%, 3.9% and 4% with continuous compounding. % The swap rate volatility is 21%, the principal is $1000, and payments % are exchanged semiannually. % Copyright 2015 The MathWorks, Inc. %% % Create the |RateSpec|. ValuationDate = 'Jan-1-2010'; EndDates = {'Jan-1-2011';'Jan-1-2012';'Jan-1-2013';'Jan-1-2014';'Jan-1-2015'}; Rates = [0.03; 0.034 ; 0.037; 0.039; 0.04;]; Compounding = -1; Basis = 1; RateSpec = intenvset('ValuationDate', ValuationDate, 'StartDates', ValuationDate, ... 'EndDates', EndDates, 'Rates', Rates, 'Compounding', Compounding,'Basis', Basis) %% % Price the swaption using the Black model. Settle = 'Jan-1-2011'; ExerciseDates = 'Jan-1-2012'; Maturity = 'Jan-1-2017'; Strike = 0.03; Volatility = 0.21; Principal =1000; Reset = 2; OptSpec = 'put'; Price = swaptionbyblk(RateSpec, OptSpec, Strike, Settle, ExerciseDates, ... Maturity, Volatility,'Basis', Basis, 'Reset', Reset,'Principal', Principal)