%% Compute the Total Return of a Fixed-Coupon Bond
% Use bndtotalreturn to compute the total return for a fixed-coupon bond, given an investment horizon date.
% Define fixed-coupon bond.

Price = 101;
CouponRate = 0.05;
Settle = '15-Nov-2011';
Maturity = '15-Nov-2031';
ReinvestRate = 0.04;

%
% Calculate the total return to maturity.

[BondEquiv, EffectiveRate] = bndtotalreturn(Price, CouponRate, ...
Settle, Maturity, ReinvestRate)

%
% Specify an investment horizon.

HorizonDate = '15-Nov-2021';
[BondEquiv, EffectiveRate] = bndtotalreturn(Price, CouponRate, ...
Settle, Maturity, ReinvestRate, 'HorizonDate', HorizonDate)

%
% Perform scenario analysis on the reinvestment rate.

ReinvestRate = [0.03; 0.035; 0.04; 0.045; 0.05];
[BondEquiv, EffectiveRate] = bndtotalreturn(Price, CouponRate, ...
Settle, Maturity, ReinvestRate, 'HorizonDate', HorizonDate)

% Copyright 2015 The MathWorks, Inc.