strange curve behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

strange curve behavior

Alexander Zvyagin
Dear all,

I encountered a very strange behavior related to QL curve discount()
method. Please, check the attached file. On my system it produces error
(see file error.txt). But if I comment out function "do_not_call_me()"
of the script (which just calls several times discount() method), the
error is gone. It is very confusing, imagine your code calls sqrt()
function and the first 100 calls are fine, but the 101st call fails...

Does any reasonable explanaition exists?

Thanks in advance,

Alexander.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

cb.py (1K) Download Attachment
error.txt (768 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: strange curve behavior

Luigi Ballabio
Hello Alexander,
    thanks for the heads up.

You're doing the first calls to discount() before setting the evaluation date explicitly.  This means that when you call do_not_call_me(), the curve is bootstrapped using the real today's date as the evaluation date.  After you set the evaluation date, you call discount() again. At this point, the curve realizes that the evaluation date has changed and bootstraps again.

As far as I can see, your problem is that the previous curve (the one bootstrapped as of today's date) is used as a guess, but it's so far off that it causes the bootstrap to fail.  My problem, instead, is that I thought we had fixed this particular case, so I'll have to look into it again.

When you don't call do_not_call_me(), instead, the curve is created but not bootstrapped right away (the calculation is lazy, and only happens when required by a call to discount() or some other method). After you set the evaluation date, the curve is bootstrapped starting from a default guess and succeeds.

Until someone looks into this, the workaround would be to move the call to do_not_call_me(curve) to after you set the evaluation date.

Later,
    Luigi



On Fri, Feb 24, 2017 at 8:45 PM Alexander <[hidden email]> wrote:
Dear all,

I encountered a very strange behavior related to QL curve discount()
method. Please, check the attached file. On my system it produces error
(see file error.txt). But if I comment out function "do_not_call_me()"
of the script (which just calls several times discount() method), the
error is gone. It is very confusing, imagine your code calls sqrt()
function and the first 100 calls are fine, but the 101st call fails...

Does any reasonable explanaition exists?

Thanks in advance,

Alexander.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users