%% Price a Sinking Fund Bond Using a BDT Interest-Rate Tree Model
% A corporation issues a three year bond with a sinking fund obligation requiring the company to sink 1/3 of face value after the first year and 1/3 after the second year. The company has the option to buy the bonds in the market or call them at $98. The following data describes the details needed for pricing the sinking fund bond:

Rates = [0.1;0.1;0.1;0.1];
ValuationDate = 'Jan-1-2011';
StartDates = ValuationDate;
EndDates = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'};
Compounding = 1;

% Create RateSpec
RateSpec = intenvset('ValuationDate', ValuationDate, 'StartDates',...
StartDates, 'EndDates', EndDates, 'Rates', Rates, 'Compounding', Compounding);

% Build the BDT tree
% Assume the volatility to be 10%
Sigma = 0.1;  
BDTTimeSpec = bdttimespec(ValuationDate, EndDates);
BDTVolSpec = bdtvolspec(ValuationDate, EndDates, Sigma*ones(1, length(EndDates))');
BDTT = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec);

% Instrument
% The bond has a coupon rate of 9%, a period of one year and matures in
% 1-Jan-2014. Face decreases 1/3 after the first year and 1/3 after the 
% second year.
CouponRate = 0.09;
Settle = 'Jan-1-2011';
Maturity =  'Jan-1-2014';
Period = 1;
Face = { ...        
            {'Jan-1-2012'  100; ...
             'Jan-1-2013'   66.6666; ...
             'Jan-1-2014'   33.3333};
        };

% Option provision
OptSpec = 'call'; 
Strike = [98 98];
ExerciseDates ={'Jan-1-2012', 'Jan-1-2013'};

% Price of non-sinking fund bond. 
PNSF = bondbybdt(BDTT, CouponRate, Settle, Maturity, Period)

%
% Price of the bond with the option sinking provision.

PriceSF = optembndbybdt(BDTT, CouponRate, Settle, Maturity,...
OptSpec, Strike, ExerciseDates,'Period', Period, 'Face', Face)

% Copyright 2015 The MathWorks, Inc.