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

Price = 101;
CouponRate = 0.05;
Settle = datetime('15-Nov-2011','Locale','en_US');
Maturity = datetime('15-Nov-2031','Locale','en_US');
HorizonDate = datetime('15-Nov-2021','Locale','en_US');
ReinvestRate = 0.04;
[BondEquiv, EffectiveRate] = bndtotalreturn(Price, CouponRate, ...
Settle, Maturity, ReinvestRate, 'HorizonDate', HorizonDate)

% Copyright 2012 The MathWorks, Inc.