This function computes the yield to maturity, given the (flat) bond price.
solveYield(buyDate, matDate, rateCoupon, bondPr, nPay)
settlement date (the date when the bond is bought)
maturity date
annual coupon rate
bond price. The flat price without accrued interest.
number of payments per year
A list with the following components:
yield to maturity
flat price
days since previous coupon payment
days in a coupon period
accrued interest since last coupon payment
invoice price (= flat price + accrued interest)
all the rates are given in decimals
Bodie, Kane, and Marcus (2014) Investments, 10th Global Edition, McGraw-Hill Education, (see Bond Pricing between Coupon Dates in Section 14.2).
bondPrice
# NOT RUN { solveYield("2012-7-31","2018-7-31",0.0225,100,2) # }
Run the code above in your browser using DataCamp Workspace