Login  Register

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

Posted by Peter Caspers-4 on Oct 06, 2014; 7:43pm
URL: http://quantlib.414.s1.nabble.com/yield-calculation-failing-when-resulting-yield-should-be-less-than-54-4-tp15932p15939.html

Hi,

I did not reproduce your case, but I know that in extreme situations
the yield bracketing fails to work, although a sensible solution
exists (e.g. if you have a cashflow -100 in a few days and +0.1 in 10
years, -69% continously compounded yield is a solution, but the
bracketing gives +147398 because then all discount factors are
numerically zero).

So my question is if the problem disappears if you replace line 968 in
cashflows.cpp from

        return solver.solve(objFunction, accuracy, guess, guess/10.0);

to (for example)

        return solver.solve(objFunction, accuracy, guess, -10.0 , 10.0);

This is not meant as a solution, only to understand your problem
better before suggesting anything.

Best regards
Peter


On 1 October 2014 16:26, ltorjul <[hidden email]> wrote:

> 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
>
>
>
>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/yield-calculation-failing-when-resulting-yield-should-be-less-than-54-4-tp15932.html
> Sent from the quantlib-dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Slashdot TV.  Videos for Nerds.  Stuff that Matters.
> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev