www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PricRangeNotHeathJarrowMortonTreeExample.m
%% Compute the Price of a Range Note Using a Heath-Jarrow-Morton Tree % This example shows how to compute the price of a range note using % a Heath-Jarrow-Morton tree with the following interest-rate term structure % data. %% % Copyright 2015 The MathWorks, Inc. Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2011'; StartDates = ValuationDate; EndDates = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'}; Compounding = 1; % define RateSpec RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,... 'EndDates', EndDates, 'Rates', Rates, 'Compounding', Compounding); % range note instrument matures in Jan-1-2014 and has the following RateSchedule: Spread = 100; Settle = 'Jan-1-2011'; Maturity = 'Jan-1-2014'; RateSched(1).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'}; RateSched(1).Rates = [0.045 0.055 ; 0.0525 0.0675; 0.06 0.08]; % data to build the tree is as follows: Volatility = [.2; .19; .18; .17]; CurveTerm = [ 1; 2; 3; 4]; MaTree = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'}; HJMTS = hjmtimespec(ValuationDate, MaTree); HJMVS = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6); HJMT = hjmtree(HJMVS, RS, HJMTS); % price the instrument Price = rangefloatbyhjm(HJMT, Spread, Settle, Maturity, RateSched)