# How can i calculate the yield given price, or price given yield for a callable bond, with several callable dates and strike prices (quantlib)

import QuantLib as ql

ql.Settings.instance().evaluationDate = ql.Date(2,3,2020)
maturity = ql.Date(10, 5, 2023)
coupon = 0.09
issueDate = ql.Date(30, 12, 2019)
frequency = ql.Semiannual
dayCount = ql.Thirty360()
price = 104.5
bond = ql.FixedRateBond(2, ql.TARGET(), 100.0, issueDate, maturity, ql.Period(frequency), [coupon], dayCount)
yld = bond.bondYield(price, dayCount, ql.Compounded,frequency)
print(yld)

cleanPrice = bond.cleanPrice(yld, dayCount, ql.Compounded, frequency)
print(cleanPrice)

dirtyPrice = bond.dirtyPrice(yld, dayCount, ql.Compounded, frequency)
print(dirtyPrice)

accrued = (dirtyPrice - cleanPrice)
print(accrued)

• One cannot properly compute call option value (and hence correctly estimate yield) without some kind of calibrated stochastic model of interest rates. If you want a simple one, QuantLib provides Black-Karasinski. I have no idea if the implementation is any good. Jul 6 '20 at 14:00

## 1 Answer

You get yield to maturity (YTM) - the yield assuming the calls are not exercised even if they are in the money.

According to the master himself http://quantlib.10058.n7.nabble.com/Yield-to-call-for-callable-bonds-td17004.html

there's no straighforward way. One workaround would be to instantiate a second bond with maturity equal to the callability date of the first, and calculate the yield on that one.

There does not seem to be a straighforward way to have yields that e.g. Bloomberg Terminal YA screen provides - yield to worst, yield to next call, etc.