yield calculation failing when resulting yield should be less than -54.4%
Posted by ltorjul on Oct 01, 2014; 2:26pm
URL: http://quantlib.414.s1.nabble.com/yield-calculation-failing-when-resulting-yield-should-be-less-than-54-4-tp15932.html
Hi,
I have a problem it seems that BondFunctions::Yield(...) is failing when the yield should be -54.4% or less (more negative). The yield function throws the exception: "unable to bracket root in 100 function evaluations(last bracket attempt: f[-2.29538e+025,5.968e+025] -> [-1.#END, 51.1682])".
I have adjusted the price gradually and it seams that the most negative resulting yield I can compute without getting this error is -54,40688%.
I have tested this with various types of bonds, both fixed rate and floating rate. And look to be that the error occurs at a prices that gives yields exactly this yield or less (more negative).
Now, it may seem like a minor problem, when will prices be high enough to give such a negative yield?
1. What causes this error, and why at this point, logically yield should be able to anywhere from -100% to infinite positive)?
2. My scenario is that I want to compute duration and convexity for floating rate bonds. The street convention is to compute these with yield to next coupon date. Since I have not found any way to calculate yield to other dates than maturity, I fix this by creating a second floating rate bonds object with maturity equal to next coupon date for the first. Then using this to calculate yield to next coupon. In this situation the yield is often quite a bit negative, so this problem do occur quite often.
Could somebody please look into this?
Perhaps I can omit the entire problem by calculating yield to next coupon differently, but I cannot see how.
Thanks in advance.
Regards Lauritz