ZeroCurve in Python

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

ZeroCurve in Python

Birgir Arnarson
Dear list,

I need advice on the use of ZeroCurve in Python.

In one of the great IPython notebook examples (http://www.implementingquantlib.com/2015/05/quantlib-notebook-duration-of-floating.html) Luigi demonstrates the convenience of using a QuoteHandle in a FlatForward termstructure. Using the QuoteHandle, one can change the curve rate and reprice the instrument with great convenience. 

As I understand it, this is not possible with the ZeroCurve. If I link an instrument to a ZeroCurve and want to change the curve rates, I'll need to create a new ZeroCurve object and link it to the instrument (via its YieldTermStructureHandle). This is most inconvenient. This is because ZeroCurve can only be constructed using a list of numbers, not a list of handles. 

Quantlib itself has a constructor that supports a vector of QuoteHandles. Is it difficult to enhance the SWIG interface to allow for this constructor as well on the Python side, or are there alternative solutions?


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

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

Re: ZeroCurve in Python

Luigi Ballabio
Hello,
    exporting another constructor to SWIG wouldn't be difficult. The problem is that the constructor isn't really there: the passed vector of handles doesn't contain the rates, but an optional series of jumps to model the end-of-year effect. All the existing constructors take the rates as a vector<Rate>, that is, a list of numbers.

Adding another constructor to InterpolatedZeroCurve (the C++ class, I mean) is possible but tricky. The class should store the vector of handles, register with all of them and update the vector of rates and the interpolation when any of the quotes is set a new value. It would add quite a bit of complexity to the class, so it might be a better idea to inherit from it and make the modifications in the derived class.

Hope this helps,
    Luigi



On Tue, Sep 22, 2015 at 10:42 AM Birgir Arnarson <[hidden email]> wrote:
Dear list,

I need advice on the use of ZeroCurve in Python.

In one of the great IPython notebook examples (http://www.implementingquantlib.com/2015/05/quantlib-notebook-duration-of-floating.html) Luigi demonstrates the convenience of using a QuoteHandle in a FlatForward termstructure. Using the QuoteHandle, one can change the curve rate and reprice the instrument with great convenience. 

As I understand it, this is not possible with the ZeroCurve. If I link an instrument to a ZeroCurve and want to change the curve rates, I'll need to create a new ZeroCurve object and link it to the instrument (via its YieldTermStructureHandle). This is most inconvenient. This is because ZeroCurve can only be constructed using a list of numbers, not a list of handles. 

Quantlib itself has a constructor that supports a vector of QuoteHandles. Is it difficult to enhance the SWIG interface to allow for this constructor as well on the Python side, or are there alternative solutions?

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