Negative Rates - QuantLib Python - Cap / Floors - QL_NEGATIVE_RATES ??

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

Negative Rates - QuantLib Python - Cap / Floors - QL_NEGATIVE_RATES ??

Anthony Calleja
Hi Community,

I am using a QuantLib Python (quantlib-python v1.9) Extension package WHL plugin  (from http://www.lfd.uci.edu/~gohlke/pythonlibs/)  installed into Spyder python-3.5.3.amd64.

I've run into the below runtime error when valuing a capped floating rate bond and this error is also reproducible with the attached python code.

It looks like this problem can be resolved if I enable the QL_NEGATIVE_RATES setting but I can't find a way to do this in Python.  Is this feature available here or is it only available in C?

Traceback (most recent call last):
  File "C:\Users\cala\workspace\ScrapBook\src\negative.py", line 44, in <module>
    print(cap.NPV())
  File "C:\dev\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\QuantLib\QuantLib.py", line 8918, in NPV
    return _QuantLib.Instrument_NPV(self)
RuntimeError: forward + displacement (-0.00738464 + 0) must be positive

Thanks

Anthony


------------------------------------------------------------------------------
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

negative.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Negative Rates - QuantLib Python - Cap / Floors - QL_NEGATIVE_RATES ??

Luigi Ballabio
Hello,
    negative rates have been enabled by default for a while now, so you don't have to do it.  The problem is that, regardless of what the settings say, you can't put a negative rate in a logarithm.  You'll need to use a displacement together with your volatility (google for "shifted lognormal interest rate model" if you're not familiar with the idea).  If the volatility you have is a quoted one, it's very likely that it was calculated with a displacement already and you'll have to ask your provider.  If you calculated it yourself instead, you'll have to choose a displacement and use it to recalculate the volatility.

Hope this helps,
    Luigi


On Thu, Jul 27, 2017 at 2:39 PM Anthony Calleja <[hidden email]> wrote:
Hi Community,

I am using a QuantLib Python (quantlib-python v1.9) Extension package WHL plugin  (from http://www.lfd.uci.edu/~gohlke/pythonlibs/)  installed into Spyder python-3.5.3.amd64.

I've run into the below runtime error when valuing a capped floating rate bond and this error is also reproducible with the attached python code.

It looks like this problem can be resolved if I enable the QL_NEGATIVE_RATES setting but I can't find a way to do this in Python.  Is this feature available here or is it only available in C?

Traceback (most recent call last):
  File "C:\Users\cala\workspace\ScrapBook\src\negative.py", line 44, in <module>
    print(cap.NPV())
  File "C:\dev\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\QuantLib\QuantLib.py", line 8918, in NPV
    return _QuantLib.Instrument_NPV(self)
RuntimeError: forward + displacement (-0.00738464 + 0) must be positive

Thanks

Anthony

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Negative Rates - QuantLib Python - Cap / Floors - QL_NEGATIVE_RATES ??

Anthony Calleja
Thank you very much Luigi.  I'm trying to find a python code example where this displacement parameter is passed. I've found the displacement documented in the C files though.

Should you know that this parameter is not supported in python kindly shout back.

Thanks

Anthony


On Thu, Jul 27, 2017 at 2:50 PM Luigi Ballabio <[hidden email]> wrote:
Hello,
    negative rates have been enabled by default for a while now, so you don't have to do it.  The problem is that, regardless of what the settings say, you can't put a negative rate in a logarithm.  You'll need to use a displacement together with your volatility (google for "shifted lognormal interest rate model" if you're not familiar with the idea).  If the volatility you have is a quoted one, it's very likely that it was calculated with a displacement already and you'll have to ask your provider.  If you calculated it yourself instead, you'll have to choose a displacement and use it to recalculate the volatility.

Hope this helps,
    Luigi


On Thu, Jul 27, 2017 at 2:39 PM Anthony Calleja <[hidden email]> wrote:
Hi Community,

I am using a QuantLib Python (quantlib-python v1.9) Extension package WHL plugin  (from http://www.lfd.uci.edu/~gohlke/pythonlibs/)  installed into Spyder python-3.5.3.amd64.

I've run into the below runtime error when valuing a capped floating rate bond and this error is also reproducible with the attached python code.

It looks like this problem can be resolved if I enable the QL_NEGATIVE_RATES setting but I can't find a way to do this in Python.  Is this feature available here or is it only available in C?

Traceback (most recent call last):
  File "C:\Users\cala\workspace\ScrapBook\src\negative.py", line 44, in <module>
    print(cap.NPV())
  File "C:\dev\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\QuantLib\QuantLib.py", line 8918, in NPV
    return _QuantLib.Instrument_NPV(self)
RuntimeError: forward + displacement (-0.00738464 + 0) must be positive

Thanks

Anthony

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Negative Rates - QuantLib Python - Cap / Floors - QL_NEGATIVE_RATES ??

Luigi Ballabio
Hmm.  No, it doesn't seem to be exported yet.  Let me know if you add it to the wrappers.  Otherwise, please open an issue at <https://github.com/lballabio/QuantLib-SWIG/issues>.

Luigi


On Thu, Jul 27, 2017 at 3:31 PM Anthony Calleja <[hidden email]> wrote:
Thank you very much Luigi.  I'm trying to find a python code example where this displacement parameter is passed. I've found the displacement documented in the C files though.

Should you know that this parameter is not supported in python kindly shout back.

Thanks

Anthony


On Thu, Jul 27, 2017 at 2:50 PM Luigi Ballabio <[hidden email]> wrote:
Hello,
    negative rates have been enabled by default for a while now, so you don't have to do it.  The problem is that, regardless of what the settings say, you can't put a negative rate in a logarithm.  You'll need to use a displacement together with your volatility (google for "shifted lognormal interest rate model" if you're not familiar with the idea).  If the volatility you have is a quoted one, it's very likely that it was calculated with a displacement already and you'll have to ask your provider.  If you calculated it yourself instead, you'll have to choose a displacement and use it to recalculate the volatility.

Hope this helps,
    Luigi


On Thu, Jul 27, 2017 at 2:39 PM Anthony Calleja <[hidden email]> wrote:
Hi Community,

I am using a QuantLib Python (quantlib-python v1.9) Extension package WHL plugin  (from http://www.lfd.uci.edu/~gohlke/pythonlibs/)  installed into Spyder python-3.5.3.amd64.

I've run into the below runtime error when valuing a capped floating rate bond and this error is also reproducible with the attached python code.

It looks like this problem can be resolved if I enable the QL_NEGATIVE_RATES setting but I can't find a way to do this in Python.  Is this feature available here or is it only available in C?

Traceback (most recent call last):
  File "C:\Users\cala\workspace\ScrapBook\src\negative.py", line 44, in <module>
    print(cap.NPV())
  File "C:\dev\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\QuantLib\QuantLib.py", line 8918, in NPV
    return _QuantLib.Instrument_NPV(self)
RuntimeError: forward + displacement (-0.00738464 + 0) must be positive

Thanks

Anthony

------------------------------------------------------------------------------
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