bdttree - Tree building failed to converge for level 5 of BDT Tree

2 views (last 30 days)
I am trying to build a 5-year BDT tree (monthly step) using bdttree function. The risk free rate and volatility assumptions are in the attached file. I am getting a warning saying "Tree building failed to converge for level 5 of BDT Tree". If I use quarterly step, there is no problem. However, I have to use monthly step to capture optionality of the instrument I am trying to value, but it does not work. I have pasted my code below. Could anyone help me understand what the problem is and how to fix it? Thanks!
if true
% code
%%Contractual Terms
valDate = datenum('4/13/2017');
IssueDate = datenum('4/13/2017');
FirstCouponDate = datenum('5/5/2017');
MaturityDate = datenum('4/13/2022');
freq = 12;
%%Risk-free rates & Vols
data = csvread('bdttree inputs.csv',1,0);
data_rates = data(:,2)/100;
data_vols = data(:,3)/100;
data_term = data(:,1);
data_rates = freq*((1+data_rates).^(1/freq)-1);
%%Construct BDT tree
bdtDates = cfdates(valDate, MaturityDate, freq, 1,1,IssueDate,FirstCouponDate)';
t = yearfrac(valDate,bdtDates,1);
Rates = interp1(data_term, data_rates, t,'linear');
Vols = spline(data_term, data_vols, t);
BDTVolSpec = bdtvolspec(valDate, bdtDates, Vols);
RateSpec = intenvset('Compounding', freq,...
'ValuationDate', valDate,...
'StartDates', valDate,...
'EndDates', bdtDates,...
'Rates', Rates);
BDTTimeSpec = bdttimespec(valDate, bdtDates, freq);
BDTTree = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec);
end

Accepted Answer

Kawee Numpacharoen
Kawee Numpacharoen on 8 Aug 2017
I have looked at your code. First, it is important to know that we may not be able to have a feasible solution all the time. The error you got is "Tree building failed to converge". After looking at the data, my initial guess is volatility might cause the problems as it ranges from >200% to 40%. I try replace volatility with smaller number after csvread.
data(:,3) = [5:0.5:10.5]';
Then you code can run.
  2 Comments
ww
ww on 7 Jun 2018
I always have the same issue when I'm trying to build the BDT tree in matlab, too.
dToday = '30-Dec-2015';
% conventions
bdc = 'follow';
dc = 3; % Actual/365
Compounding = 1; % Annual compounding
% holidays
H = []
% ---------------------------------------
% generate the settlement dates
% ---------------------------------------
dnToday = datenum(dToday);
dnSpot = busdate( addtodate(dnToday, 2, 'day'), bdc, H );
dn1m = busdate( addtodate(dnSpot, 1, 'month'), bdc, H );
dn3m = busdate( addtodate(dnSpot, 3, 'month'), bdc, H );
dn6m = busdate( addtodate(dnSpot, 6, 'month'), bdc, H );
dn9m = busdate( addtodate(dnSpot, 9, 'month'), bdc, H );
dn1y = busdate( addtodate(dnSpot, 1, 'year' ), bdc, H );
dn2y = busdate( addtodate(dnSpot, 2, 'year' ), bdc, H );
dn3y = busdate( addtodate(dnSpot, 3, 'year' ), bdc, H );
dn4y = busdate( addtodate(dnSpot, 4, 'year' ), bdc, H );
dn5y = busdate( addtodate(dnSpot, 5, 'year' ), bdc, H );
dn6y = busdate( addtodate(dnSpot, 6, 'year' ), bdc, H );
dn7y = busdate( addtodate(dnSpot, 7, 'year' ), bdc, H );
dn8y = busdate( addtodate(dnSpot, 8, 'year' ), bdc, H );
dn9y = busdate( addtodate(dnSpot, 9, 'year' ), bdc, H );
dn10y = busdate( addtodate(dnSpot, 10, 'year' ), bdc, H );
dn11y = busdate( addtodate(dnSpot, 11, 'year' ), bdc, H );
dn12y = busdate( addtodate(dnSpot, 12, 'year' ), bdc, H );
dn13y = busdate( addtodate(dnSpot, 13, 'year' ), bdc, H );
dn14y = busdate( addtodate(dnSpot, 14, 'year' ), bdc, H );
dn15y = busdate( addtodate(dnSpot, 15, 'year' ), bdc, H );
dn16y = busdate( addtodate(dnSpot, 16, 'year' ), bdc, H );
dn17y = busdate( addtodate(dnSpot, 17, 'year' ), bdc, H );
dn18y = busdate( addtodate(dnSpot, 18, 'year' ), bdc, H );
dn19y = busdate( addtodate(dnSpot, 19, 'year' ), bdc, H );
dn20y = busdate( addtodate(dnSpot, 20, 'year' ), bdc, H );
d1m = datestr(dn1m);
d3m = datestr(dn3m);
d6m = datestr(dn6m);
d9m = datestr(dn9m);
d1y = datestr(dn1y);
d2y = datestr(dn2y);
d3y = datestr(dn3y);
d4y = datestr(dn4y);
d5y = datestr(dn5y);
d6y = datestr(dn6y);
d7y = datestr(dn7y);
d8y = datestr(dn8y);
d9y = datestr(dn9y);
d10y = datestr(dn10y);
d11y = datestr(dn11y);
d12y = datestr(dn12y);
d13y = datestr(dn13y);
d14y = datestr(dn14y);
d15y = datestr(dn15y);
d16y = datestr(dn16y);
d17y = datestr(dn17y);
d18y = datestr(dn18y);
d19y = datestr(dn19y);
d20y = datestr(dn20y);
% ---------------------------------------
% yield curves
% ---------------------------------------
% 'InstrumentPeriod', 2, 'InstrumentBasis', dc
TenorTypes = { ...
'Deposit';'Deposit';'Deposit';'Deposit'; ...
'Swap';'Swap';'Swap';'Swap';'Swap';'Swap';'Swap';'Swap';'Swap'};
TenorRates = [
dn1m, 0.0150;
dn3m, 0.0150;
dn6m, 0.0151;
dn1y, 0.0150;
dn2y, 0.0159;
dn3y, 0.0174;
dn4y, 0.0183;
dn5y, 0.0224;
dn7y, 0.0240;
dn10y, 0.0257;
dn12y, 0.0287;
dn15y, 0.0307;
dn20y, 0.0362;
];
ZeroRates = IRBootstrap(dnToday, TenorRates, TenorTypes, dc);
ZeroRates = TenorRates(:,2);
% ---------------------------------------
% volatilities
% ---------------------------------------
vol = [
dn1m, 0.0418;
dn3m, 0.0418;
dn6m, 0.0418;
dn1y, 0.0418;
dn2y, 0.0418;
dn3y, 0.0418;
dn4y, 0.0418;
dn5y, 0.0418;
dn7y, 0.0418;
dn10y, 0.0418;
dn12y, 0.0418;
dn15y, 0.0418;
dn20y, 0.0418;
];
% ---------------------------------------
% build the BDT trees
% ---------------------------------------
BDTdt = 1; % days
BDTEndDate = dn160;
timespec = (dnToday+BDTdt:BDTdt:BDTEndDate);
BDTTS = bdttimespec(dnToday, timespec, 1);
BDTVS = bdtvolspec(dnToday, vol(:,1), vol(:,2));
RS = intenvset( ...
'ValuationDate', dnToday, 'StartDates', dnToday, ...
'EndDates', TenorRates(:,1), 'Rates', ZeroRates, ...
'Compounding', -1 ...
);
BDTT = bdttree(BDTVS, RS, BDTTS);
For this simple case with flat volatility term structure, it still fail. Anyways, it seems to be ok when BDTdt is greater than 20. But I still have no idea how to fix it systematically and how to get exact BDT tree I want. What are the criteria to successfully build the BDT tree? What volatility convention is used in bdtvolspec? Annualized vol? Forward vol?
ww
ww on 7 Jun 2018
sorry for the missing code:
dn160 = busdate( addtodate(dnSpot, 6*32, 'month'), bdc, H );

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!