%% Price a Convertible Bond Using a CRR Tree and Incorporate Default Risk Using DefaultProbability and RecoveryRate
% Create the interest-rate term structure RateSpec.

StartDates = 'Jan-1-2014'; 
EndDates = 'Jan-1-2016'; 
Rates = 0.025; 
Basis = 1; 
RateSpec = intenvset('ValuationDate',StartDates,'StartDates',...
StartDates,'EndDates',EndDates,'Rates',Rates,'Compounding',-1,'Basis',Basis)

%
% Create the StockSpec.

AssetPrice = 110; 
Sigma = 0.22; 
Div = 0.02; 
StockSpec = stockspec(Sigma,AssetPrice,'continuous',Div)

%
% Create the CRR tree for the equity.

Settle = '1-Jan-2014';
Maturity = '1-Oct-2014';
NumSteps = 3;
TimeSpec = crrtimespec(Settle,Maturity,NumSteps);
CRRT = crrtree(StockSpec,RateSpec,TimeSpec)

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

CouponRate = 0;
Period = 1;
ConvRatio = 2;
CallExDates = '1-Oct-2014';
CallStrike = 115;
AmericanCall = 1;
DefaultProbability = .30;
RecoveryRate = .82;

[Price,PriceTree,EqtTree,DbtTree] = cbondbycrr(CRRT,CouponRate,Settle,Maturity,ConvRatio,...
'Period',Period,'CallExDates',CallExDates,'CallStrike',CallStrike,'AmericanCall',AmericanCall,...
'DefaultProbability',DefaultProbability,'RecoveryRate',RecoveryRate)

% Copyright 2012 The MathWorks, Inc.