%% Price Convertible Bond Using an EQP Tree
% 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 EQP tree for the equity.

NumSteps = 6;
TimeSpec = eqptimespec(StartDates,EndDates,NumSteps);
EQPTree = eqptree(StockSpec,RateSpec,TimeSpec)

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

Settle = 'Jan-1-2014'; 
Maturity = 'Jan-1-2016'; 
CouponRate = 0.03;
CallStrike = 125; 
Period = 1;
CallExDates = [datenum('Jan-1-2015') datenum('Jan-1-2016')];
ConvRatio = 1.5;

%
% Price the convertible bond.

Spread = 0.045;

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

% Copyright 2015 The MathWorks, Inc.