www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceRangeNotBlackDermanToyTreeExample.m

    %% Compute the Price of a Range Note Using a Black-Derman-Toy Tree
% This example shows how to compute the price of a range note using a
% Black-Derman-Toy 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:
% assume the volatility is 10%.
Sigma = 0.1;  
BDTTS = bdttimespec(ValuationDate, EndDates, Compounding);
BDTVS = bdtvolspec(ValuationDate, EndDates, Sigma*ones(1, length(EndDates))');
BDTT = bdttree(BDTVS, RS, BDTTS);

% price the instrument 
Price = rangefloatbybdt(BDTT, Spread, Settle, Maturity, RateSched)