Subclassing (the RateHelper) in Python
Posted by ago-2 on
URL: http://quantlib.414.s1.nabble.com/Subclassing-the-RateHelper-in-Python-tp4133.html
Hi,
I am trying to subclass the RateHelper using python, so that the
derived class (Inflation Linked Bond) can be used within the
bootstrapper. I am struggling my way through c++, swig and the wrapper
code, and so far I failed miserably with the error:
NotImplementedError: No matching function for overloaded
'new_PiecewiseFlatForward'
This error normally relates to wrong type of constructor arguments,
but in this case it seems more complex and I gave up trying to
understand the wrapper code.
I then tried the "easier" task of subclassing (in python) the
SwapRateHelper, overriding some of the methods for testing purposes.
I have no problem using derived classes in other python code, but when
instances of such classes are consumed within QL, the overridden
methods are not called, the ones of the base class are used instead
:-(
E.g. in the bootstrapper PiecewiseFlatForward::performCalculations(),
the overridden discountGuess() is never called. This is a bit of a
show stopper.
Can this type of subclassing be done in Python or am I wasting my
time? If yes, how? Or should I write c++ code and then use swig? Or
some other python extension technique? What have others done so far?