Swaption pricing with negative rates in python

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

Swaption pricing with negative rates in python

Björn
Hello,

I was really excited when I learned that support for negative rates had been added to the QL option models. However, I can't get the shifted normal model or the Bachelier model to work via the QL-Python SWIG bindings. Is there a tutorial available showing how to use them?

What I'm trying to do is something along the lines:

vol1  = QuoteHandle(SimpleQuote(0.1533))
swaption1.setPricingEngine(BlackSwaptionEngine(termStructure, vol1, -0.03))
swaption2.setPricingEngine(BachelierSwaptionEngine(termStructure, vol1))

But already the first setPricingEngine() fails:

  File "<stdin>", line 1, in <module>
  File "EuropeanSwaption.py", line 207, in <module>
    swaption1.setPricingEngine(BlackSwaptionEngine(termStructure,vol1,-0.03))
  File "/Library/Python/2.7/site-packages/QuantLib/QuantLib.py", line 17495, in __init__
    this = _QuantLib.new_BlackSwaptionEngine(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_BlackSwaptionEngine'.
  Possible C/C++ prototypes are:
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle< YieldTermStructure > const &,Handle< Quote > const &)
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle< YieldTermStructure > const &,Handle< SwaptionVolatilityStructure > const &)

What am I doing wrong here?

Thanks,
Björn
Reply | Threaded
Open this post in threaded view
|

Re: Swaption pricing with negative rates in python

Luigi Ballabio
Hello Bjorn,
    sorry for the late answer. I didn't have much time to give to the mailing list this month.

The normal and displaced lognormal model are not available in the current release of the Python bindings, but Peter Caspers just opened a pull request that adds them.  You can find it at <https://github.com/lballabio/QuantLib-SWIG/pull/32>; if you want to try it, you can check out the changes from Peter's fork and rebuild the module. Drop me a line if you need instructions.

Luigi


On Sat, Sep 10, 2016 at 8:24 PM Björn <[hidden email]> wrote:
Hello,

I was really excited when I learned that support for negative rates had been
added to the QL option models. However, I can't get the shifted normal model
or the Bachelier model to work via the QL-Python SWIG bindings. Is there a
tutorial available showing how to use them?

What I'm trying to do is something along the lines:

vol1  = QuoteHandle(SimpleQuote(0.1533))
swaption1.setPricingEngine(BlackSwaptionEngine(termStructure, vol1, -0.03))
swaption2.setPricingEngine(BachelierSwaptionEngine(termStructure, vol1))

But already the first setPricingEngine() fails:

  File "<stdin>", line 1, in <module>
  File "EuropeanSwaption.py", line 207, in <module>

swaption1.setPricingEngine(BlackSwaptionEngine(termStructure,vol1,-0.03))
  File "/Library/Python/2.7/site-packages/QuantLib/QuantLib.py", line 17495,
in __init__
    this = _QuantLib.new_BlackSwaptionEngine(*args)
NotImplementedError: Wrong number or type of arguments for overloaded
function 'new_BlackSwaptionEngine'.
  Possible C/C++ prototypes are:
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle<
YieldTermStructure > const &,Handle< Quote > const &)
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle<
YieldTermStructure > const &,Handle< SwaptionVolatilityStructure > const &)

What am I doing wrong here?

Thanks,
Björn



--
View this message in context: http://quantlib.10058.n7.nabble.com/Swaption-pricing-with-negative-rates-in-python-tp17714.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swaption pricing with negative rates in python

Björn
Hi Luigi,

thanks for pointing me to Peter's PR. I'll try that and let both of you know if I encounter any issues.

Many thanks
Björn

On 26 September 2016 at 21:28, Luigi Ballabio [via QuantLib] <[hidden email]> wrote:
Hello Bjorn,
    sorry for the late answer. I didn't have much time to give to the mailing list this month.

The normal and displaced lognormal model are not available in the current release of the Python bindings, but Peter Caspers just opened a pull request that adds them.  You can find it at <https://github.com/lballabio/QuantLib-SWIG/pull/32>; if you want to try it, you can check out the changes from Peter's fork and rebuild the module. Drop me a line if you need instructions.

Luigi


On Sat, Sep 10, 2016 at 8:24 PM Björn <[hidden email]> wrote:
Hello,

I was really excited when I learned that support for negative rates had been
added to the QL option models. However, I can't get the shifted normal model
or the Bachelier model to work via the QL-Python SWIG bindings. Is there a
tutorial available showing how to use them?

What I'm trying to do is something along the lines:

vol1  = QuoteHandle(SimpleQuote(0.1533))
swaption1.setPricingEngine(BlackSwaptionEngine(termStructure, vol1, -0.03))
swaption2.setPricingEngine(BachelierSwaptionEngine(termStructure, vol1))

But already the first setPricingEngine() fails:

  File "<stdin>", line 1, in <module>
  File "EuropeanSwaption.py", line 207, in <module>

swaption1.setPricingEngine(BlackSwaptionEngine(termStructure,vol1,-0.03))
  File "/Library/Python/2.7/site-packages/QuantLib/QuantLib.py", line 17495,
in __init__
    this = _QuantLib.new_BlackSwaptionEngine(*args)
NotImplementedError: Wrong number or type of arguments for overloaded
function 'new_BlackSwaptionEngine'.
  Possible C/C++ prototypes are:
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle<
YieldTermStructure > const &,Handle< Quote > const &)
    BlackSwaptionEnginePtr::BlackSwaptionEnginePtr(Handle<
YieldTermStructure > const &,Handle< SwaptionVolatilityStructure > const &)

What am I doing wrong here?

Thanks,
Björn



--
View this message in context: http://quantlib.10058.n7.nabble.com/Swaption-pricing-with-negative-rates-in-python-tp17714.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



If you reply to this email, your message will be added to the discussion below:
http://quantlib.10058.n7.nabble.com/Swaption-pricing-with-negative-rates-in-python-tp17714p17759.html
To unsubscribe from Swaption pricing with negative rates in python, click here.
NAML