%% Compute OAS Using the Black-Derman-Toy (BDT) Model
% This example shows how to compute OAS using the Black-Derman-Toy (BDT) model with the following data.

ValuationDate = 'Oct-1-2010';
Rates = [0.035; 0.042; 0.047; 0.052];
StartDates = ValuationDate;
EndDates = datemnth(ValuationDate, 12:12:48)';
Compounding = 1;
% define RateSpec
RateSpec = intenvset('ValuationDate', ValuationDate,...
'StartDates', StartDates, 'EndDates', EndDates, ...
'Rates', Rates, 'Compounding', Compounding); 

% specify VolSpec and TimeSpec
Sigma = 0.20;
VS = bdtvolspec(ValuationDate, EndDates, Sigma*ones(size(EndDates)));
TS = bdttimespec(ValuationDate, EndDates, Compounding);

% build the BDT tree
BDTTree = bdttree(VS, RateSpec, TS);
BDTTreenew = cvtree(BDTTree);

% instrument information
CouponRate = 0.065;
Settle = ValuationDate;
Maturity = '01-Oct-2014';
OptSpec = 'call';
Strike = 100;
ExerciseDates ='01-Oct-2011';
Period = 1;
Price = 101.58;

% compute the OAS
OAS = oasbybdt(BDTTree, Price, CouponRate, Settle, Maturity,...
OptSpec, Strike, ExerciseDates, 'Period', Period)

% Copyright 2012 The MathWorks, Inc.