Login  Register

Re: SwapRateHelper Question - SWIG Python

Posted by Luigi Ballabio on May 27, 2014; 3:48pm
URL: http://quantlib.414.s1.nabble.com/SwapRateHelper-Question-SWIG-Python-tp15297p15314.html

The constructor is exported in the latest version of the code (see
<https://github.com/lballabio/quantlib/blob/master/QuantLib-SWIG/SWIG/ratehelpers.i>)
and it seems to work. Are you sure you're not picking up an old
installed version of the module? In the "Possible C/C++ prototypes
are:....* error message, is the one with the additional parameter
listed? If so, can you provide a small script that initializes the
parameters you're passing and reproduces the problem?

Luigi


On Wed, May 21, 2014 at 6:27 PM, Ioan F. <[hidden email]> wrote:

> Hello,
>
> I am trying to expose a new type of the SwapRateHelper constructor (already
> existent in QuantLib) to Python.
> In the ratehelpers.i interface file, I added the following code:
>
> //ADDED
>
> *SwapRateHelperPtr(
>               const Handle& rate,
>         const Period &tenor,
>         const Calendar &calendar,
>         Frequency fixedFrequency,
>         BusinessDayConvention fixedConvention,
>         const DayCounter &fixedDayCount,
>         const boost::shared_ptr<IborIndex> &index,
>         const Handle &spread=Handle(),
>         const Period &fwdStart=0 *Days,
>         const Handle<YieldTermStructure>
> &discountingCurve=Handle<YieldTermStructure>()) {
>                 boost::shared_ptr<IborIndex> libor =
>                         boost::dynamic_pointer_cast<IborIndex>(index);
>                            return new SwapRateHelperPtr(
>                            new SwapRateHelper(rate, tenor, calendar,
>                                    fixedFrequency, fixedConvention,
>                                    fixedDayCount, libor,
>                                    spread, fwdStart,
>                         discountingCurve));*
>
> //END ADDED
>
> I was able to wrap, build and install the QuantLib library (via SWIG) into
> Python, but when I try to use the SwapRateHelper in Python, I get the
> following error:
>
>  *NotImplementedError: Wrong number or type of arguments for overloaded
> function 'new_SwapRateHelper'.
>   Possible C/C++ prototypes are:....*
>
> The following code works:
>
> *qqq=SwapRateHelper(QuoteHandle(eurLiborSwaps[(2, Years)]),
>                             Period(2, Years),
>                             euroCalendar,
>                             fixedLegFrequency,
>                             fixedLegAdjustment,
>                             fixedLegDayCounter,
>                             EURLibor3M(),
>                             QuoteHandle(),
>                             Period(0,0))*
>
> while this one causes the problem:
>
> *qqq=SwapRateHelper(QuoteHandle(eurLiborSwaps[(2, Years)]),
>                             Period(2, Years),
>                             euroCalendar,
>                             fixedLegFrequency,
>                             fixedLegAdjustment,
>                             fixedLegDayCounter,
>                             EURLibor3M(),
>                             QuoteHandle(),
>                             Period(0,0),
>                             eoniaHandle)*
>
> Furthermore, please note that Python reports the type of the eoniaHandle
> variable as:
>
> *QuantLib.QuantLib.YieldTermStructureHandle*
>
> Any help or suggestions are highly appreciated.
> Since this is my first time posting, please excuse any breaking of the
> "mailing list etiquette."
>
> Thank you,
> Ioan
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/SwapRateHelper-Question-SWIG-Python-tp15297.html
> Sent from the quantlib-dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev