Login  Register

Re: yield calculation failing when resulting yield should be less than -54.4%

Posted by ltorjul on Oct 08, 2014; 3:41pm
URL: http://quantlib.414.s1.nabble.com/yield-calculation-failing-when-resulting-yield-should-be-less-than-54-4-tp15932p15952.html

Hi,

Thanks for your answer!

I tested your suggestion and changed line 968 in the cashflows.cpp file to:
return solver.solve(objFunction, accuracy, guess, -10.0 , 10.0);

This causes the error:
root not bracketed: f[-10,10] -> [-1.#IND00e+000,5.999990e+004]

I guess the reason is that a root of -10 cannot exist. If you look at the question from a financial perspective, you can off course loose you entire investment (Which would give a yield of -100%), but you could never get in the situation where you owe money (i.e. yield cannot be < -100%). Not sure if this makes any sense to you.

Anyway I tested with:
return solver.solve(objFunction, accuracy, guess, -1.0 , 10.0);
and this seems to work. I'm able to calculate yield in those extreme cases where yield is less than -54.4%.

I have also tested the unmodified yield function with a difference initial guess, e.g.
yield(frb, cleanPrice, dayCounter, QuantLib::Compounded, coupCompfrequency, settlementDate, 1e-8, 100, -0.80)

and it seems that using an initial guess of -.8 (-80%) "moves" the limit where the problem occures to about -91%. This however this causes the solver to work about 15% slower :-(

Anyway I like the solution where you sets the upper and lower limits better.

I'm good with this solution. But if you have other ideas or remarks I would be very grateful.

Regards Laurtiz