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)

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

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

accrued = (dirtyPrice - cleanPrice)
  • $\begingroup$ 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. $\endgroup$ – Brian B Jul 6 '20 at 14:00

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.