%% Price a Convertible Bond Using an STT Tree and Incorporate Default Risk Using DefaultProbability and RecoveryRate
% Create the interest-rate term structure 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 the StockSpec.

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

%
% Create the STT tree for the equity.

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

%
% Define and price the convertible bond using the optional DefaultProbability and RecoveryRate arguments.

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;
DefaultProbability = .30;
RecoveryRate = .82;

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

% Copyright 2012 The MathWorks, Inc.