www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PutSwaptionHWInterestRateTreeExample.m
%% Price a 3-Year Put Swaption Using an HW Interest-Rate Tree % This example shows how to price a 3-year put swaption using an HW interest-rate tree with the following data. %% % Copyright 2015 The MathWorks, Inc. Rates =0.075 * ones (10,1); Compounding = 2; StartDates = ['jan-1-2007';'jul-1-2007';'jan-1-2008';'jul-1-2008';'jan-1-2009';... 'jul-1-2009';'jan-1-2010'; 'jul-1-2010';'jan-1-2011';'jul-1-2011']; EndDates =['jul-1-2007';'jan-1-2008';'jul-1-2008';'jan-1-2009';'jul-1-2009';... 'jan-1-2010';'jul-1-2010';'jan-1-2011';'jul-1-2011';'jan-1-2012']; ValuationDate = 'jan-1-2007'; % define the RatesSpec RateSpec = intenvset('Rates', Rates, 'StartDates', StartDates, 'EndDates',... EndDates, 'Compounding', Compounding); % use HWVolSpec to compute the interest-rate volatility Volatility = 0.05*ones(10,1); AlphaCurve = 0.01*ones(10,1); AlphaDates = EndDates; HWVolSpec = hwvolspec(ValuationDate, EndDates, Volatility, AlphaDates, AlphaCurve); % use HWTimeSpec to specify the structure of the time layout for an HW interest-rate tree HWTimeSpec = hwtimespec(ValuationDate, EndDates, Compounding); % build the HW tree HWTree = hwtree(HWVolSpec, RateSpec, HWTimeSpec); % use the following arguments for a 1-year swap and 3-year swaption ExerciseDates = 'jan-1-2010'; SwapSettlement = ExerciseDates; SwapMaturity = 'jan-1-2012'; Spread = 0; SwapReset = 2 ; Principal = 100; OptSpec = 'put'; Strike= 0.04; Basis=1; % price the swaption PriceSwaption = swaptionbyhw(HWTree, OptSpec, Strike, ExerciseDates, ... Spread, SwapSettlement, SwapMaturity,'SwapReset', SwapReset, ... 'Basis', Basis,'Principal', Principal)