Python: SwapRateHelper

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

Python: SwapRateHelper

Chuck Swiger-4
Hi All - Enjoying the project very much. I'm trying to implement
bonds.cpp in Python and stuck at:

        boost::shared_ptr<RateHelper> s2y(new SwapRateHelper(
                Handle<Quote>(s2yRate),
                2*Years,
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                Handle<Quote>(),
                forwardStart));

getting an error about wrong number of args, using:

>>> s2y =
SwapRateHelper(QuoteHandle(s2yRate),Period(2,Years),calendar,swFixedLegFrequency,swFixedLegConvention, swFixedLegDayCounter,swFloatingLegIndex,QuoteHandle(),forwardStart)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/QuantLib/QuantLib.py", line
7160, in __init__
    this = _QuantLib.new_SwapRateHelper(*args)
NotImplementedError: Wrong number of arguments for overloaded function
'new_SwapRateHelper'.
  Possible C/C++ prototypes are:
    SwapRateHelperPtr(Handle< Quote > const &,Period const &,Calendar
const &,Frequency,BusinessDayConvention,DayCounter const &,IborIndexPtr
const &)
    SwapRateHelperPtr(Rate,Period const &,Calendar const
&,Frequency,BusinessDayConvention,DayCounter const &,IborIndexPtr const
&)



The SWIG wrapper has two candidates, the closest being:

        *new_SwapRateHelperPtr__SWIG_0(
                Handle< Quote > const &rate,
                Period const &tenor,
                Calendar const &calendar,
                Frequency fixedFrequency,
                BusinessDayConvention fixedConvention,
                DayCounter const &fixedDayCount,
                IborIndexPtr const &index){
        boost::shared_ptr<IborIndex> libor =
                boost::dynamic_pointer_cast<IborIndex>(index);
        ...
        new SwapRateHelper(rate, tenor, calendar,
                fixedFrequency, fixedConvention,
                fixedDayCount, libor));


and the ql srcratehelpers.cpp has the correct  matching argument list:

        SwapRateHelper::SwapRateHelper(const Handle<Quote>& rate,
                                   const Period& tenor,
                                   const Calendar& calendar,
                                   Frequency fixedFrequency,
                                   BusinessDayConvention fixedConvention,
                                   const DayCounter& fixedDayCount,
                                   const shared_ptr<IborIndex>& iborIndex,
                                   const Handle<Quote>& spread,
                                   const Period& fwdStart)

Does this mean the Python wrapper is incomplete for implementing bonds.cpp, or am I missing something??

Thanks!

--Chuck




------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Python: SwapRateHelper

Luigi Ballabio
On Wed, 2009-09-16 at 06:43 -0400, Charles Swiger wrote:
> Hi All - Enjoying the project very much. I'm trying to implement
> bonds.cpp in Python and stuck at:
>
> boost::shared_ptr<RateHelper> s2y(new SwapRateHelper(...)
>
> getting an error about wrong number of args [...]
>
> Does this mean the Python wrapper is incomplete for implementing
> bonds.cpp, or am I missing something??

The wrapper is missing a couple of arguments. You can try and add them
to the SWIG interface file---or you can just ignore them and go ahead
with the example.  The quote is empty anyway, and the 1-day forward
start will modify the floating rates a bit but won't change the point of
the example.  You can compile Bonds.cpp with forwardStart = 0*Days to
check the results.

Luigi

P.S. Of course you're welcome to contribute the example...


--

Can't act. Slightly bald. Also dances.
-- RKO executive, reacting to Fred Astaire's screen test.
Cerf/Navasky, "The Experts Speak"



------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Python: SwapRateHelper

Chuck Swiger-4
On Wed, 2009-09-16 at 15:02 +0200, Luigi Ballabio wrote:

> On Wed, 2009-09-16 at 06:43 -0400, Charles Swiger wrote:
> > Hi All - Enjoying the project very much. I'm trying to implement
> > bonds.cpp in Python and stuck at:
> >
> > boost::shared_ptr<RateHelper> s2y(new SwapRateHelper(...)
> >
> > getting an error about wrong number of args [...]
> >
> > Does this mean the Python wrapper is incomplete for implementing
> > bonds.cpp, or am I missing something??
>
> The wrapper is missing a couple of arguments. You can try and add them
> to the SWIG interface file---or you can just ignore them and go ahead
> with the example.  The quote is empty anyway, and the 1-day forward
> start will modify the floating rates a bit but won't change the point of
> the example.  You can compile Bonds.cpp with forwardStart = 0*Days to
> check the results.
>

Ok, I'll try to add them to the SWIG interface file as it's looks like
it won't work with ANY python args.

Doing these in Python is good learning exercise, then using the ql in a
gui like wyPython is not too difficult.

--Chuck


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users