www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceRangeNoteAHullWhiteTreeExample.m
%% Compute the Price of a Range Note Using a Hull-White Tree % This example shows how to compute the price of a range note using a % Hull-White 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: VolDates = ['1-Jan-2012'; '1-Jan-2013'; '1-Jan-2014';'1-Jan-2015']; VolCurve = 0.01; AlphaDates = '01-01-2015'; AlphaCurve = 0.1; HWVS = hwvolspec(RS.ValuationDate, VolDates, VolCurve,... AlphaDates, AlphaCurve); HWTS = hwtimespec(RS.ValuationDate, VolDates, Compounding); HWT = hwtree(HWVS, RS, HWTS); % price the instrument Price = rangefloatbyhw(HWT, Spread, Settle, Maturity, RateSched)