www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceCallSwaptionHJMIntRateTrExample.m
%% Price a 1-Year Call Swaption Using an HJM Interest-Rate Tree % This example shows how to price a 1-year call swaption using an HJM % interest-rate tree. Assume that interest rate is fixed at 5% annually % between the valuation date of the tree until its maturity. Build a tree % with the following data. %% % Copyright 2015 The MathWorks, Inc. Rates = [ 0.05;0.05;0.05;0.05]; StartDates = 'jan-1-2007'; EndDates =['jan-1-2008';'jan-1-2009';'jan-1-2010';'jan-1-2011']; ValuationDate = StartDates; Compounding = 1; % define the RateSpec RateSpec = intenvset('Rates', Rates, 'StartDates', StartDates, 'EndDates',... EndDates, 'Compounding', Compounding); % use VolSpec to compute the interest-rate volatility VolSpec=hjmvolspec('Constant',0.01); % use TimeSpec to specify the structure of the time layout for the HJM interest-rate tree TimeSpec = hjmtimespec(ValuationDate, EndDates, Compounding); % build the HJM tree HJMTree = hjmtree(VolSpec, RateSpec, TimeSpec); % use the following swaption arguments ExerciseDates = '01-Jan-2008'; SwapSettlement = ExerciseDates; SwapMaturity = 'jan-1-2010'; Spread = [0]; SwapReset = 1; Basis = 1; Principal = 100; OptSpec = 'call'; Strike=0.05; % price the swaption [Price, PriceTree] = swaptionbyhjm(HJMTree, OptSpec, Strike, ExerciseDates, ... Spread, SwapSettlement, SwapMaturity,'SwapReset', SwapReset, ... 'Basis', Basis, 'Principal', Principal)