%% Price a Convertible Bond Using a STTTree
% Create a RateSpec.

StartDates = 'Jan-1-2015'; 
EndDates = 'Jan-1-2020'; 
Rates = 0.025; 
Basis = 1; 

RateSpec = intenvset('ValuationDate',StartDates,'StartDates',StartDates,...
'EndDates',EndDates,'Rates',Rates,'Compounding',-1,'Basis',Basis)

%
% Create a StockSpec.

AssetPrice = 80; 
Sigma = 0.12; 
StockSpec = stockspec(Sigma,AssetPrice)

%
% Create a STTTree.

TimeSpec = stttimespec(StartDates, EndDates, 20);
STTTree = stttree(StockSpec, RateSpec, TimeSpec)

%
% Define the convertible bond. The convertible bond can be called starting on Jan 1, 2016 with a strike price of 95.

CouponRate = 0.03;
Settle = 'Jan-1-2015'; 
Maturity = 'April-1-2018'; 
Period = 1;
CallStrike = 95; 
CallExDates = [datenum('Jan-1-2016') datenum('April-1-2018')];
ConvRatio = 1;
Spread = 0.025;

%
% Price the convertible bond using the standard trinomial tree model.

[Price,PriceTree,EqtTre,DbtTree] = cbondbystt(STTTree,CouponRate,Settle,Maturity,ConvRatio,...
'Period',Period,'Spread',Spread,'CallExDates',CallExDates,'CallStrike',CallStrike,'AmericanCall',1)

% Copyright 2015 The MathWorks, Inc.