Adding functions to QuantLib SWIG

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

Adding functions to QuantLib SWIG

Zhi Xuan Fang
Hi,

I am currently working on QuantLib SWIG 1.0 with SWIG version 1.3.29. I am having troubles adding functions to a class. For example adding the function int addlfunc(){ return 1;} to class Quote. From the marketelements.i file, I tried 

%{
using QuantLib::Quote;
%}

%ignore Quote;
class Quote {
  public:
    Real value() const;
    %extend{
      int addlfunc(){
return 1;
      }
    }
};

however it doesn't build. I am new to SWIG but when I was looking at their documentation, %extend seems to be the answer. 

In addition, does quantlib swig not allow reference to vectors as a function argument? I am trying to open up marketmodels to QuantLib SWIG. the nextStep function of BrownianGenerators takes in a reference to vectors as a function argument and I am unable to get it working like the other simpler functions of numberOfSteps, numberOfFactors, etc. 

Thanks for any help provided.

Regards,
Zhi Xuan

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2

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

Re: Adding functions to QuantLib SWIG

Billy Ng-5
Hi,
 
As an exercise, I am trying to convert the SwapValuation example into Java.
Any example in how to convert new classes with SWIG, e.g. PieceWiseYieldCurve?
 
Billy
-----Original Message-----
From: Zhi Xuan Fang [mailto:[hidden email]]
Sent: Tuesday, April 17, 2012 6:12 AM
To: [hidden email]
Subject: [Quantlib-users] Adding functions to QuantLib SWIG

Hi,

I am currently working on QuantLib SWIG 1.0 with SWIG version 1.3.29. I am having troubles adding functions to a class. For example adding the function int addlfunc(){ return 1;} to class Quote. From the marketelements.i file, I tried 

%{
using QuantLib::Quote;
%}

%ignore Quote;
class Quote {
  public:
    Real value() const;
    %extend{
      int addlfunc(){
return 1;
      }
    }
};

however it doesn't build. I am new to SWIG but when I was looking at their documentation, %extend seems to be the answer. 

In addition, does quantlib swig not allow reference to vectors as a function argument? I am trying to open up marketmodels to QuantLib SWIG. the nextStep function of BrownianGenerators takes in a reference to vectors as a function argument and I am unable to get it working like the other simpler functions of numberOfSteps, numberOfFactors, etc. 

Thanks for any help provided.

Regards,
Zhi Xuan

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
It doesn't really answer the question, but you should already have all
the classes you need for swap valuation (you can see how it's done in
the Python examples, for instance).

As for how to convert new classes, I'll have to write down some docs
on that when I have some time.  In the meantime, I'm afraid you'll
have to look at the existing interfaces and do some cargo-cult
programming.  Do post again if you get stuck (it's easier to find time
for a specific problem with some code).

Luigi

On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
> Hi,
>
> As an exercise, I am trying to convert the SwapValuation example into Java.
> Any example in how to convert new classes with SWIG, e.g.
> PieceWiseYieldCurve?

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
In reply to this post by Zhi Xuan Fang
On Tue, Apr 17, 2012 at 12:11 AM, Zhi Xuan Fang <[hidden email]> wrote:

> I am currently working on QuantLib SWIG 1.0 with SWIG version 1.3.29. I am
> having troubles adding functions to a class. For example adding the function
> int addlfunc(){ return 1;} to class Quote. From the marketelements.i file, I
> tried
>
> %{
> using QuantLib::Quote;
> %}
>
> %ignore Quote;
> class Quote {
>   public:
>     Real value() const;
>     %extend{
>       int addlfunc(){
> return 1;
>       }
>     }
> };
>
> however it doesn't build. I am new to SWIG but when I was looking at their
> documentation, %extend seems to be the answer.

Yes, but the class actually exported as Quote to the target language
is boost::shared_ptr<Quote>.  Try extending that, as in:

%extend boost::shared_ptr<Quote> {
    int addlfunc(){
        return 1;
    }
}


> In addition, does quantlib swig not allow reference to vectors as a function
> argument?

That's tricky.  What language are you exporting to?

Luigi

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-6
In reply to this post by Luigi Ballabio
How to translate this YieldTermStructure?
There is no PiecewiseYieldCurve<Discount, Lognormal>
Billy
--
Sent from my Defy

Luigi Ballabio <[hidden email]> wrote:
It doesn't really answer the question, but you should already have all
the classes you need for swap valuation (you can see how it's done in
the Python examples, for instance).

As for how to convert new classes, I'll have to write down some docs
on that when I have some time. In the meantime, I'm afraid you'll
have to look at the existing interfaces and do some cargo-cult
programming. Do post again if you get stuck (it's easier to find time
for a specific problem with some code).

Luigi

On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
> Hi,
>
> As an exercise, I am trying to convert the SwapValuation example into Java.
> Any example in how to convert new classes with SWIG, e.g.
> PieceWiseYieldCurve?


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
Right now there's a PiecewiseFlatForward exported which is
PiecewiseYieldCurve<ForwardRate, BackwardFlat>.

If you want more combinations, you have to modify
piecewiseyieldcurve.i (look at the bottom of the file; there's a few
examples) and regenerate the wrappers.

Luigi

On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:

> How to translate this YieldTermStructure?
> There is no PiecewiseYieldCurve<Discount, Lognormal>
> Billy
> --
> Sent from my Defy
>
>
> Luigi Ballabio <[hidden email]> wrote:
>>
>> It doesn't really answer the question, but you should already have all
>> the classes you need for swap valuation (you can see how it's done in
>> the Python examples, for instance).
>>
>> As for how to convert new classes, I'll have to write down some docs
>> on that when I have some time.  In the meantime, I'm afraid you'll
>> have to look at the existing interfaces and do some cargo-cult
>> programming.  Do post again if you get stuck (it's easier to find time
>> for a specific problem with some code).
>>
>> Luigi
>>
>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>> > Hi,
>> >
>> > As an exercise, I am trying to convert the SwapValuation example into
>> > Java.
>> > Any example in how to convert new classes with SWIG, e.g.
>> > PieceWiseYieldCurve?
>>
>

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-5

Thank you.
It should generate all the needed template classes

Billy

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 12:15 AM
To: Billy Ng
Cc: Billy Ng; [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG


Right now there's a PiecewiseFlatForward exported which is
PiecewiseYieldCurve<ForwardRate, BackwardFlat>.

If you want more combinations, you have to modify
piecewiseyieldcurve.i (look at the bottom of the file; there's a few
examples) and regenerate the wrappers.

Luigi

On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:

> How to translate this YieldTermStructure?
> There is no PiecewiseYieldCurve<Discount, Lognormal>
> Billy
> --
> Sent from my Defy
>
>
> Luigi Ballabio <[hidden email]> wrote:
>>
>> It doesn't really answer the question, but you should already have all
>> the classes you need for swap valuation (you can see how it's done in
>> the Python examples, for instance).
>>
>> As for how to convert new classes, I'll have to write down some docs
>> on that when I have some time.  In the meantime, I'm afraid you'll
>> have to look at the existing interfaces and do some cargo-cult
>> programming.  Do post again if you get stuck (it's easier to find time
>> for a specific problem with some code).
>>
>> Luigi
>>
>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>> > Hi,
>> >
>> > As an exercise, I am trying to convert the SwapValuation example into
>> > Java.
>> > Any example in how to convert new classes with SWIG, e.g.
>> > PieceWiseYieldCurve?
>>
>
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-5
Hi Luigi,

I am wondering which example has classese that have not exported yet so that I can give it a trial.
That should be a good reference to try out the SWIG

Many Thanks for your help

Billy

-----Original Message-----
From: Billy Ng [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 12:51 AM
To: Luigi Ballabio
Cc: [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG



Thank you.
It should generate all the needed template classes

Billy

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 12:15 AM
To: Billy Ng
Cc: Billy Ng; [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG


Right now there's a PiecewiseFlatForward exported which is
PiecewiseYieldCurve<ForwardRate, BackwardFlat>.

If you want more combinations, you have to modify
piecewiseyieldcurve.i (look at the bottom of the file; there's a few
examples) and regenerate the wrappers.

Luigi

On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:

> How to translate this YieldTermStructure?
> There is no PiecewiseYieldCurve<Discount, Lognormal>
> Billy
> --
> Sent from my Defy
>
>
> Luigi Ballabio <[hidden email]> wrote:
>>
>> It doesn't really answer the question, but you should already have all
>> the classes you need for swap valuation (you can see how it's done in
>> the Python examples, for instance).
>>
>> As for how to convert new classes, I'll have to write down some docs
>> on that when I have some time.  In the meantime, I'm afraid you'll
>> have to look at the existing interfaces and do some cargo-cult
>> programming.  Do post again if you get stuck (it's easier to find time
>> for a specific problem with some code).
>>
>> Luigi
>>
>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>> > Hi,
>> >
>> > As an exercise, I am trying to convert the SwapValuation example into
>> > Java.
>> > Any example in how to convert new classes with SWIG, e.g.
>> > PieceWiseYieldCurve?
>>
>
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
The CallableBonds example.

Luigi

On Thu, Apr 19, 2012 at 1:53 AM, Billy Ng <[hidden email]> wrote:

> Hi Luigi,
>
> I am wondering which example has classese that have not exported yet so that I can give it a trial.
> That should be a good reference to try out the SWIG
>
> Many Thanks for your help
>
> Billy
>
> -----Original Message-----
> From: Billy Ng [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:51 AM
> To: Luigi Ballabio
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
>
> Thank you.
> It should generate all the needed template classes
>
> Billy
>
> -----Original Message-----
> From: Luigi Ballabio [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:15 AM
> To: Billy Ng
> Cc: Billy Ng; [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
> Right now there's a PiecewiseFlatForward exported which is
> PiecewiseYieldCurve<ForwardRate, BackwardFlat>.
>
> If you want more combinations, you have to modify
> piecewiseyieldcurve.i (look at the bottom of the file; there's a few
> examples) and regenerate the wrappers.
>
> Luigi
>
> On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:
>> How to translate this YieldTermStructure?
>> There is no PiecewiseYieldCurve<Discount, Lognormal>
>> Billy
>> --
>> Sent from my Defy
>>
>>
>> Luigi Ballabio <[hidden email]> wrote:
>>>
>>> It doesn't really answer the question, but you should already have all
>>> the classes you need for swap valuation (you can see how it's done in
>>> the Python examples, for instance).
>>>
>>> As for how to convert new classes, I'll have to write down some docs
>>> on that when I have some time.  In the meantime, I'm afraid you'll
>>> have to look at the existing interfaces and do some cargo-cult
>>> programming.  Do post again if you get stuck (it's easier to find time
>>> for a specific problem with some code).
>>>
>>> Luigi
>>>
>>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > As an exercise, I am trying to convert the SwapValuation example into
>>> > Java.
>>> > Any example in how to convert new classes with SWIG, e.g.
>>> > PieceWiseYieldCurve?
>>>
>>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-6
In the swap valuation example.
The following change will cause a boostrapping of the curves

        boost::shared_ptr<SimpleQuote> fiveYearsRate =
            boost::dynamic_pointer_cast<SimpleQuote>(s5yRate);
        fiveYearsRate->setValue(0.0460);

How do I do a similar dynamic pointer casting in SWIG/Java?

Billy
-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 3:16 PM
To: Billy Ng
Cc: [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG


The CallableBonds example.

Luigi

On Thu, Apr 19, 2012 at 1:53 AM, Billy Ng <[hidden email]> wrote:

> Hi Luigi,
>
> I am wondering which example has classese that have not exported yet so that I can give it a trial.
> That should be a good reference to try out the SWIG
>
> Many Thanks for your help
>
> Billy
>
> -----Original Message-----
> From: Billy Ng [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:51 AM
> To: Luigi Ballabio
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
>
> Thank you.
> It should generate all the needed template classes
>
> Billy
>
> -----Original Message-----
> From: Luigi Ballabio [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:15 AM
> To: Billy Ng
> Cc: Billy Ng; [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
> Right now there's a PiecewiseFlatForward exported which is
> PiecewiseYieldCurve<ForwardRate, BackwardFlat>.
>
> If you want more combinations, you have to modify
> piecewiseyieldcurve.i (look at the bottom of the file; there's a few
> examples) and regenerate the wrappers.
>
> Luigi
>
> On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:
>> How to translate this YieldTermStructure?
>> There is no PiecewiseYieldCurve<Discount, Lognormal>
>> Billy
>> --
>> Sent from my Defy
>>
>>
>> Luigi Ballabio <[hidden email]> wrote:
>>>
>>> It doesn't really answer the question, but you should already have all
>>> the classes you need for swap valuation (you can see how it's done in
>>> the Python examples, for instance).
>>>
>>> As for how to convert new classes, I'll have to write down some docs
>>> on that when I have some time.  In the meantime, I'm afraid you'll
>>> have to look at the existing interfaces and do some cargo-cult
>>> programming.  Do post again if you get stuck (it's easier to find time
>>> for a specific problem with some code).
>>>
>>> Luigi
>>>
>>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > As an exercise, I am trying to convert the SwapValuation example into
>>> > Java.
>>> > Any example in how to convert new classes with SWIG, e.g.
>>> > PieceWiseYieldCurve?
>>>
>>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-5
In the swap valuation example.
The following change will cause a boostrapping of the curves

        boost::shared_ptr<SimpleQuote> fiveYearsRate =
            boost::dynamic_pointer_cast<SimpleQuote>(s5yRate);
        fiveYearsRate->setValue(0.0460);

How do I do a similar dynamic pointer casting in SWIG/Java?

Billy
-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 3:16 PM
To: Billy Ng
Cc: [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG


The CallableBonds example.

Luigi

On Thu, Apr 19, 2012 at 1:53 AM, Billy Ng <[hidden email]> wrote:

> Hi Luigi,
>
> I am wondering which example has classese that have not exported yet so that I can give it a trial.
> That should be a good reference to try out the SWIG
>
> Many Thanks for your help
>
> Billy
>
> -----Original Message-----
> From: Billy Ng [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:51 AM
> To: Luigi Ballabio
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
>
> Thank you.
> It should generate all the needed template classes
>
> Billy
>
> -----Original Message-----
> From: Luigi Ballabio [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:15 AM
> To: Billy Ng
> Cc: Billy Ng; [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
> Right now there's a PiecewiseFlatForward exported which is
> PiecewiseYieldCurve<ForwardRate, BackwardFlat>.
>
> If you want more combinations, you have to modify
> piecewiseyieldcurve.i (look at the bottom of the file; there's a few
> examples) and regenerate the wrappers.
>
> Luigi
>
> On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:
>> How to translate this YieldTermStructure?
>> There is no PiecewiseYieldCurve<Discount, Lognormal>
>> Billy
>> --
>> Sent from my Defy
>>
>>
>> Luigi Ballabio <[hidden email]> wrote:
>>>
>>> It doesn't really answer the question, but you should already have all
>>> the classes you need for swap valuation (you can see how it's done in
>>> the Python examples, for instance).
>>>
>>> As for how to convert new classes, I'll have to write down some docs
>>> on that when I have some time.  In the meantime, I'm afraid you'll
>>> have to look at the existing interfaces and do some cargo-cult
>>> programming.  Do post again if you get stuck (it's easier to find time
>>> for a specific problem with some code).
>>>
>>> Luigi
>>>
>>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > As an exercise, I am trying to convert the SwapValuation example into
>>> > Java.
>>> > Any example in how to convert new classes with SWIG, e.g.
>>> > PieceWiseYieldCurve?
>>>
>>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Billy Ng-5
In reply to this post by Luigi Ballabio
Hi Luigi,

For the CallableBonds Example, I need to set up the SWIG file for these two classes
TreeCallableFixedRateBondEngine
CallableFixedRateBond

What are the good SWIG file references for these two classes?

Billy

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, April 19, 2012 3:16 PM
To: Billy Ng
Cc: [hidden email]
Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG


The CallableBonds example.

Luigi

On Thu, Apr 19, 2012 at 1:53 AM, Billy Ng <[hidden email]> wrote:

> Hi Luigi,
>
> I am wondering which example has classese that have not exported yet so that I can give it a trial.
> That should be a good reference to try out the SWIG
>
> Many Thanks for your help
>
> Billy
>
> -----Original Message-----
> From: Billy Ng [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:51 AM
> To: Luigi Ballabio
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
>
> Thank you.
> It should generate all the needed template classes
>
> Billy
>
> -----Original Message-----
> From: Luigi Ballabio [mailto:[hidden email]]
> Sent: Thursday, April 19, 2012 12:15 AM
> To: Billy Ng
> Cc: Billy Ng; [hidden email]
> Subject: Re: [Quantlib-users] Adding functions to QuantLib SWIG
>
>
> Right now there's a PiecewiseFlatForward exported which is
> PiecewiseYieldCurve<ForwardRate, BackwardFlat>.
>
> If you want more combinations, you have to modify
> piecewiseyieldcurve.i (look at the bottom of the file; there's a few
> examples) and regenerate the wrappers.
>
> Luigi
>
> On Wed, Apr 18, 2012 at 6:07 PM, Billy Ng <[hidden email]> wrote:
>> How to translate this YieldTermStructure?
>> There is no PiecewiseYieldCurve<Discount, Lognormal>
>> Billy
>> --
>> Sent from my Defy
>>
>>
>> Luigi Ballabio <[hidden email]> wrote:
>>>
>>> It doesn't really answer the question, but you should already have all
>>> the classes you need for swap valuation (you can see how it's done in
>>> the Python examples, for instance).
>>>
>>> As for how to convert new classes, I'll have to write down some docs
>>> on that when I have some time.  In the meantime, I'm afraid you'll
>>> have to look at the existing interfaces and do some cargo-cult
>>> programming.  Do post again if you get stuck (it's easier to find time
>>> for a specific problem with some code).
>>>
>>> Luigi
>>>
>>> On Wed, Apr 18, 2012 at 1:27 PM, Billy Ng <[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > As an exercise, I am trying to convert the SwapValuation example into
>>> > Java.
>>> > Any example in how to convert new classes with SWIG, e.g.
>>> > PieceWiseYieldCurve?
>>>
>>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

smazzucca
I am also trying to convert CallableFixedRateBond using SWIG.

I made some progress by copying the FixedRateBond segment in bonds.i, but at the end of the day I'm getting errors when trying to compile.

Where exactly are the samples ? I don't see them anywhere ?

Thank you,
Simon
Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
Hi,
    I'm not sure what samples you're referring to? Anyway, I can have
a look at your SWIG interface if you post it here.

Luigi


On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:

> I am also trying to convert CallableFixedRateBond using SWIG.
>
> I made some progress by copying the FixedRateBond segment in bonds.i, but at
> the end of the day I'm getting errors when trying to compile.
>
> Where exactly are the samples ? I don't see them anywhere ?
>
> Thank you,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

RE: Adding functions to QuantLib SWIG

smazzucca

I was referring to this, previously in the same thread:

 

>If you want more combinations, you have to modify piecewiseyieldcurve.i (look at the bottom of the file; there's a few examples) and regenerate the wrappers.

 

I added this segment in bonds.i:

 

%rename(CallableFixedRateBond) CallableFixedRateBondPtr;

class CallableFixedRateBondPtr : public BondPtr {

    %feature("kwargs") CallableFixedRateBondPtr;

  public:

    %extend {

        CallableFixedRateBondPtr(

                Integer settlementDays,

                Real faceAmount,

                const Schedule &schedule,

                const std::vector<Rate>& coupons,

                const DayCounter& accrualDayCounter,

                BusinessDayConvention paymentConvention,

                Real redemption,

                Date issueDate,

                const CallabilitySchedule &putCallSchedule) {

            return new CallableFixedRateBondPtr(

                new CallableFixedRateBond(settlementDays, faceAmount,

                                  schedule, coupons, accrualDayCounter,

                                  paymentConvention, redemption,

                                  issueDate, putCallSchedule));

        }

    }

};

 

Thanks so much!

S

 

 

From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
Sent: Monday, December 16, 2013 10:59 AM
To: Simon Mazzucca
Subject: Re: Adding functions to QuantLib SWIG

 

Hi,
    I'm not sure what samples you're referring to? Anyway, I can have
a look at your SWIG interface if you post it here.

Luigi


On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:


> I am also trying to convert CallableFixedRateBond using SWIG.
>
> I made some progress by copying the FixedRateBond segment in bonds.i, but at
> the end of the day I'm getting errors when trying to compile.
>
> Where exactly are the samples ? I don't see them anywhere ?
>
> Thank you,
> Simon
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users




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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html

To unsubscribe from Adding functions to QuantLib SWIG, click here.
NAML





This e-mail, including its contents and attachments, if any, is confidential and is intended only for the addressee. If you are not the intended recipient, you are hereby notified that any use, dissemination or distribution of this communication is strictly forbidden. If you received this e-mail in error please immediately notify the sender and delete or destroy this and all copies of this message and all attachments. Any unauthorized disclosure, use, distribution, or reproduction of this message or any attachments is prohibited and may be unlawful.

Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
I see. The examples are the ones commented at the end of the file:

// combine traits as you wish, e.g.,
// export_piecewise_curve(PiecewiseLinearForward,ForwardRate,Linear);
// export_piecewise_curve(PiecewiseLinearZero,ZeroYield,Linear);
// export_piecewise_curve(PiecewiseCubicZero,ZeroYield,Cubic);

As for your callable-bond wrapper, it looks correct, but I think you
also have to add

using QuantLib::CallableFixedRateBond;

and

typedef boost::shared_ptr<Instrument> CallableFixedRateBondPtr;

among the other similar declarations at the beginning of bonds.i
(they're part of a scheme to hide shared_ptr, which are not idiomatic
in the languages we're exporting to).

Luigi



On Mon, Dec 16, 2013 at 5:07 PM, smazzucca <[hidden email]> wrote:

> I was referring to this, previously in the same thread:
>
>
>
>>If you want more combinations, you have to modify piecewiseyieldcurve.i
>> (look at the bottom of the file; there's a few examples) and regenerate the
>> wrappers.
>
>
>
> I added this segment in bonds.i:
>
>
>
> %rename(CallableFixedRateBond) CallableFixedRateBondPtr;
>
> class CallableFixedRateBondPtr : public BondPtr {
>
>     %feature("kwargs") CallableFixedRateBondPtr;
>
>   public:
>
>     %extend {
>
>         CallableFixedRateBondPtr(
>
>                 Integer settlementDays,
>
>                 Real faceAmount,
>
>                 const Schedule &schedule,
>
>                 const std::vector<Rate>& coupons,
>
>                 const DayCounter& accrualDayCounter,
>
>                 BusinessDayConvention paymentConvention,
>
>                 Real redemption,
>
>                 Date issueDate,
>
>                 const CallabilitySchedule &putCallSchedule) {
>
>             return new CallableFixedRateBondPtr(
>
>                 new CallableFixedRateBond(settlementDays, faceAmount,
>
>                                   schedule, coupons, accrualDayCounter,
>
>                                   paymentConvention, redemption,
>
>                                   issueDate, putCallSchedule));
>
>         }
>
>     }
>
> };
>
>
>
> Thanks so much!
>
> S
>
>
>
>
>
> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
> Sent: Monday, December 16, 2013 10:59 AM
> To: Simon Mazzucca
> Subject: Re: Adding functions to QuantLib SWIG
>
>
>
> Hi,
>     I'm not sure what samples you're referring to? Anyway, I can have
> a look at your SWIG interface if you post it here.
>
> Luigi
>
>
> On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:
>
>
>> I am also trying to convert CallableFixedRateBond using SWIG.
>>
>> I made some progress by copying the FixedRateBond segment in bonds.i, but
>> at
>> the end of the day I'm getting errors when trying to compile.
>>
>> Where exactly are the samples ? I don't see them anywhere ?
>>
>> Thank you,
>> Simon
>>
>>
>>
>> --
>> View this message in context:
>> http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html
>
> To unsubscribe from Adding functions to QuantLib SWIG, click here.
> NAML
>
>
>
>
>
> This e-mail, including its contents and attachments, if any, is confidential
> and is intended only for the addressee. If you are not the intended
> recipient, you are hereby notified that any use, dissemination or
> distribution of this communication is strictly forbidden. If you received
> this e-mail in error please immediately notify the sender and delete or
> destroy this and all copies of this message and all attachments. Any
> unauthorized disclosure, use, distribution, or reproduction of this message
> or any attachments is prohibited and may be unlawful.
>
>
> ________________________________
> View this message in context: RE: Adding functions to QuantLib SWIG
>
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

RE: Adding functions to QuantLib SWIG

smazzucca

Sorry, I did have those declarations at the top. But when I build the c wrapper (NQuantLibc) I get 3 errors and 1 warning:

 

error C2061: syntax error : identifier 'CallabilitySchedule'

...\csharp\cpp\quantlib_wrap.cpp

Line: 5575

 

error C2065: 'putCallSchedule' : undeclared identifier

...\csharp\cpp\quantlib_wrap.cpp

Line: 5580

 

error C2660: 'new_CallableFixedRateBondPtr' : function does not take 9 arguments       

...\csharp\cpp\quantlib_wrap.cpp

Line: 78439

 

warning C4005: 'SWIGSTDCALL' : macro redefinition

...\csharp\cpp\quantlib_wrap.cpp

Line: 339

 

The first 2 error point here:

 

SWIGINTERN CallableFixedRateBondPtr *new_CallableFixedRateBondPtr(Integer settlementDays,Real faceAmount,Schedule const &schedule,std::vector< Rate > const &coupons,DayCounter const &accrualDayCounter,BusinessDayConvention paymentConvention,Real redemption,Date issueDate,CallabilitySchedule const &putCallSchedule){

            return new CallableFixedRateBondPtr(

                new CallableFixedRateBond(settlementDays, faceAmount,

                                  schedule, coupons, accrualDayCounter,

                                  paymentConvention, redemption,

                                  issueDate, putCallSchedule));

 

 

 

The third one here:

 

      result = (CallableFixedRateBondPtr *)new_CallableFixedRateBondPtr(arg1,arg2,(Schedule const &)*arg3,(std::vector< double > const &)*arg4,(DayCounter const &)*arg5,arg6,arg7,arg8,(CallabilitySchedule const &)*arg9);

 

Simon 

 

From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
Sent: Monday, December 16, 2013 11:26 AM
To: Simon Mazzucca
Subject: Re: Adding functions to QuantLib SWIG

 

I see. The examples are the ones commented at the end of the file:

// combine traits as you wish, e.g.,
// export_piecewise_curve(PiecewiseLinearForward,ForwardRate,Linear);
// export_piecewise_curve(PiecewiseLinearZero,ZeroYield,Linear);
// export_piecewise_curve(PiecewiseCubicZero,ZeroYield,Cubic);

As for your callable-bond wrapper, it looks correct, but I think you
also have to add

using QuantLib::CallableFixedRateBond;

and

typedef boost::shared_ptr<Instrument> CallableFixedRateBondPtr;

among the other similar declarations at the beginning of bonds.i
(they're part of a scheme to hide shared_ptr, which are not idiomatic
in the languages we're exporting to).

Luigi



On Mon, Dec 16, 2013 at 5:07 PM, smazzucca <[hidden email]> wrote:


> I was referring to this, previously in the same thread:
>
>
>
>>If you want more combinations, you have to modify piecewiseyieldcurve.i
>> (look at the bottom of the file; there's a few examples) and regenerate the
>> wrappers.
>
>
>
> I added this segment in bonds.i:
>
>
>
> %rename(CallableFixedRateBond) CallableFixedRateBondPtr;
>
> class CallableFixedRateBondPtr : public BondPtr {
>
>     %feature("kwargs") CallableFixedRateBondPtr;
>
>   public:
>
>     %extend {
>
>         CallableFixedRateBondPtr(
>
>                 Integer settlementDays,
>
>                 Real faceAmount,
>
>                 const Schedule &schedule,
>
>                 const std::vector<Rate>& coupons,
>
>                 const DayCounter& accrualDayCounter,
>
>                 BusinessDayConvention paymentConvention,
>
>                 Real redemption,
>
>                 Date issueDate,
>
>                 const CallabilitySchedule &putCallSchedule) {
>
>             return new CallableFixedRateBondPtr(
>
>                 new CallableFixedRateBond(settlementDays, faceAmount,
>
>                                   schedule, coupons, accrualDayCounter,
>
>                                   paymentConvention, redemption,
>
>                                   issueDate, putCallSchedule));
>
>         }
>
>     }
>
> };
>
>
>
> Thanks so much!
>
> S
>
>
>
>
>
> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
> Sent: Monday, December 16, 2013 10:59 AM
> To: Simon Mazzucca
> Subject: Re: Adding functions to QuantLib SWIG
>
>
>
> Hi,
>     I'm not sure what samples you're referring to? Anyway, I can have
> a look at your SWIG interface if you post it here.
>
> Luigi
>
>
> On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:
>
>
>> I am also trying to convert CallableFixedRateBond using SWIG.
>>
>> I made some progress by copying the FixedRateBond segment in bonds.i, but
>> at
>> the end of the day I'm getting errors when trying to compile.
>>
>> Where exactly are the samples ? I don't see them anywhere ?
>>
>> Thank you,
>> Simon
>>
>>
>>
>> --
>> View this message in context:
>> http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html
>
> To unsubscribe from Adding functions to QuantLib SWIG, click here.
> NAML
>
>
>
>
>
> This e-mail, including its contents and attachments, if any, is confidential
> and is intended only for the addressee. If you are not the intended
> recipient, you are hereby notified that any use, dissemination or
> distribution of this communication is strictly forbidden. If you received
> this e-mail in error please immediately notify the sender and delete or
> destroy this and all copies of this message and all attachments. Any
> unauthorized disclosure, use, distribution, or reproduction of this message
> or any attachments is prohibited and may be unlawful.
>
>
> ________________________________
> View this message in context: RE: Adding functions to QuantLib SWIG
>
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>




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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
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/Adding-functions-to-QuantLib-SWIG-tp6140p14746.html

To unsubscribe from Adding functions to QuantLib SWIG, click here.
NAML





This e-mail, including its contents and attachments, if any, is confidential and is intended only for the addressee. If you are not the intended recipient, you are hereby notified that any use, dissemination or distribution of this communication is strictly forbidden. If you received this e-mail in error please immediately notify the sender and delete or destroy this and all copies of this message and all attachments. Any unauthorized disclosure, use, distribution, or reproduction of this message or any attachments is prohibited and may be unlawful.

Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
Ok, try adding

%include callability.i

at the beginning.

Luigi


On Mon, Dec 16, 2013 at 5:39 PM, smazzucca <[hidden email]> wrote:

> Sorry, I did have those declarations at the top. But when I build the c
> wrapper (NQuantLibc) I get 3 errors and 1 warning:
>
>
>
> error C2061: syntax error : identifier 'CallabilitySchedule'
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 5575
>
>
>
> error C2065: 'putCallSchedule' : undeclared identifier
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 5580
>
>
>
> error C2660: 'new_CallableFixedRateBondPtr' : function does not take 9
> arguments
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 78439
>
>
>
> warning C4005: 'SWIGSTDCALL' : macro redefinition
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 339
>
>
>
> The first 2 error point here:
>
>
>
> SWIGINTERN CallableFixedRateBondPtr *new_CallableFixedRateBondPtr(Integer
> settlementDays,Real faceAmount,Schedule const &schedule,std::vector< Rate >
> const &coupons,DayCounter const &accrualDayCounter,BusinessDayConvention
> paymentConvention,Real redemption,Date issueDate,CallabilitySchedule const
> &putCallSchedule){
>
>             return new CallableFixedRateBondPtr(
>
>                 new CallableFixedRateBond(settlementDays, faceAmount,
>
>                                   schedule, coupons, accrualDayCounter,
>
>                                   paymentConvention, redemption,
>
>                                   issueDate, putCallSchedule));
>
>
>
>
>
>
>
> The third one here:
>
>
>
>       result = (CallableFixedRateBondPtr
> *)new_CallableFixedRateBondPtr(arg1,arg2,(Schedule const
> &)*arg3,(std::vector< double > const &)*arg4,(DayCounter const
> &)*arg5,arg6,arg7,arg8,(CallabilitySchedule const &)*arg9);
>
>
>
> Simon
>
>
>
> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
> Sent: Monday, December 16, 2013 11:26 AM
>
>
> To: Simon Mazzucca
> Subject: Re: Adding functions to QuantLib SWIG
>
>
>
> I see. The examples are the ones commented at the end of the file:
>
>
> // combine traits as you wish, e.g.,
> // export_piecewise_curve(PiecewiseLinearForward,ForwardRate,Linear);
> // export_piecewise_curve(PiecewiseLinearZero,ZeroYield,Linear);
> // export_piecewise_curve(PiecewiseCubicZero,ZeroYield,Cubic);
>
> As for your callable-bond wrapper, it looks correct, but I think you
> also have to add
>
> using QuantLib::CallableFixedRateBond;
>
> and
>
> typedef boost::shared_ptr<Instrument> CallableFixedRateBondPtr;
>
> among the other similar declarations at the beginning of bonds.i
> (they're part of a scheme to hide shared_ptr, which are not idiomatic
> in the languages we're exporting to).
>
> Luigi
>
>
>
> On Mon, Dec 16, 2013 at 5:07 PM, smazzucca <[hidden email]> wrote:
>
>
>> I was referring to this, previously in the same thread:
>>
>>
>>
>>>If you want more combinations, you have to modify piecewiseyieldcurve.i
>>> (look at the bottom of the file; there's a few examples) and regenerate
>>> the
>>> wrappers.
>>
>>
>>
>> I added this segment in bonds.i:
>>
>>
>>
>> %rename(CallableFixedRateBond) CallableFixedRateBondPtr;
>>
>> class CallableFixedRateBondPtr : public BondPtr {
>>
>>     %feature("kwargs") CallableFixedRateBondPtr;
>>
>>   public:
>>
>>     %extend {
>>
>>         CallableFixedRateBondPtr(
>>
>>                 Integer settlementDays,
>>
>>                 Real faceAmount,
>>
>>                 const Schedule &schedule,
>>
>>                 const std::vector<Rate>& coupons,
>>
>>                 const DayCounter& accrualDayCounter,
>>
>>                 BusinessDayConvention paymentConvention,
>>
>>                 Real redemption,
>>
>>                 Date issueDate,
>>
>>                 const CallabilitySchedule &putCallSchedule) {
>>
>>             return new CallableFixedRateBondPtr(
>>
>>                 new CallableFixedRateBond(settlementDays, faceAmount,
>>
>>                                   schedule, coupons, accrualDayCounter,
>>
>>                                   paymentConvention, redemption,
>>
>>                                   issueDate, putCallSchedule));
>>
>>         }
>>
>>     }
>>
>> };
>>
>>
>>
>> Thanks so much!
>>
>> S
>>
>>
>>
>>
>>
>> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
>> Sent: Monday, December 16, 2013 10:59 AM
>> To: Simon Mazzucca
>> Subject: Re: Adding functions to QuantLib SWIG
>>
>>
>>
>> Hi,
>>     I'm not sure what samples you're referring to? Anyway, I can have
>> a look at your SWIG interface if you post it here.
>>
>> Luigi
>>
>>
>> On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:
>>
>>
>>> I am also trying to convert CallableFixedRateBond using SWIG.
>>>
>>> I made some progress by copying the FixedRateBond segment in bonds.i, but
>>> at
>>> the end of the day I'm getting errors when trying to compile.
>>>
>>> Where exactly are the samples ? I don't see them anywhere ?
>>>
>>> Thank you,
>>> Simon
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
>>> http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>> organizations don't have a clear picture of how application performance
>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>> your
>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>>> Pro!
>>>
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html
>>
>> To unsubscribe from Adding functions to QuantLib SWIG, click here.
>> NAML
>>
>>
>>
>>
>>
>> This e-mail, including its contents and attachments, if any, is
>> confidential
>> and is intended only for the addressee. If you are not the intended
>> recipient, you are hereby notified that any use, dissemination or
>> distribution of this communication is strictly forbidden. If you received
>> this e-mail in error please immediately notify the sender and delete or
>> destroy this and all copies of this message and all attachments. Any
>> unauthorized disclosure, use, distribution, or reproduction of this
>> message
>> or any attachments is prohibited and may be unlawful.
>>
>>
>> ________________________________
>> View this message in context: RE: Adding functions to QuantLib SWIG
>>
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14746.html
>
> To unsubscribe from Adding functions to QuantLib SWIG, click here.
> NAML
>
>
>
>
>
> This e-mail, including its contents and attachments, if any, is confidential
> and is intended only for the addressee. If you are not the intended
> recipient, you are hereby notified that any use, dissemination or
> distribution of this communication is strictly forbidden. If you received
> this e-mail in error please immediately notify the sender and delete or
> destroy this and all copies of this message and all attachments. Any
> unauthorized disclosure, use, distribution, or reproduction of this message
> or any attachments is prohibited and may be unlawful.
>
>
> ________________________________
> View this message in context: RE: Adding functions to QuantLib SWIG
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

RE: Adding functions to QuantLib SWIG

smazzucca

Sorry, no luck. Same exact result.

 

Simon 

 

From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
Sent: Monday, December 16, 2013 11:46 AM
To: Simon Mazzucca
Subject: Re: Adding functions to QuantLib SWIG

 

Ok, try adding

%include callability.i

at the beginning.

Luigi


On Mon, Dec 16, 2013 at 5:39 PM, smazzucca <[hidden email]> wrote:


> Sorry, I did have those declarations at the top. But when I build the c
> wrapper (NQuantLibc) I get 3 errors and 1 warning:
>
>
>
> error C2061: syntax error : identifier 'CallabilitySchedule'
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 5575
>
>
>
> error C2065: 'putCallSchedule' : undeclared identifier
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 5580
>
>
>
> error C2660: 'new_CallableFixedRateBondPtr' : function does not take 9
> arguments
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 78439
>
>
>
> warning C4005: 'SWIGSTDCALL' : macro redefinition
>
> ...\csharp\cpp\quantlib_wrap.cpp
>
> Line: 339
>
>
>
> The first 2 error point here:
>
>
>
> SWIGINTERN CallableFixedRateBondPtr *new_CallableFixedRateBondPtr(Integer
> settlementDays,Real faceAmount,Schedule const &schedule,std::vector< Rate >
> const &coupons,DayCounter const &accrualDayCounter,BusinessDayConvention
> paymentConvention,Real redemption,Date issueDate,CallabilitySchedule const
> &putCallSchedule){
>
>             return new CallableFixedRateBondPtr(
>
>                 new CallableFixedRateBond(settlementDays, faceAmount,
>
>                                   schedule, coupons, accrualDayCounter,
>
>                                   paymentConvention, redemption,
>
>                                   issueDate, putCallSchedule));
>
>
>
>
>
>
>
> The third one here:
>
>
>
>       result = (CallableFixedRateBondPtr
> *)new_CallableFixedRateBondPtr(arg1,arg2,(Schedule const
> &)*arg3,(std::vector< double > const &)*arg4,(DayCounter const
> &)*arg5,arg6,arg7,arg8,(CallabilitySchedule const &)*arg9);
>
>
>
> Simon
>
>
>
> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
> Sent: Monday, December 16, 2013 11:26 AM
>
>
> To: Simon Mazzucca
> Subject: Re: Adding functions to QuantLib SWIG
>
>
>
> I see. The examples are the ones commented at the end of the file:
>
>
> // combine traits as you wish, e.g.,
> // export_piecewise_curve(PiecewiseLinearForward,ForwardRate,Linear);
> // export_piecewise_curve(PiecewiseLinearZero,ZeroYield,Linear);
> // export_piecewise_curve(PiecewiseCubicZero,ZeroYield,Cubic);
>
> As for your callable-bond wrapper, it looks correct, but I think you
> also have to add
>
> using QuantLib::CallableFixedRateBond;
>
> and
>
> typedef boost::shared_ptr<Instrument> CallableFixedRateBondPtr;
>
> among the other similar declarations at the beginning of bonds.i
> (they're part of a scheme to hide shared_ptr, which are not idiomatic
> in the languages we're exporting to).
>
> Luigi
>
>
>
> On Mon, Dec 16, 2013 at 5:07 PM, smazzucca <[hidden email]> wrote:
>
>
>> I was referring to this, previously in the same thread:
>>
>>
>>
>>>If you want more combinations, you have to modify piecewiseyieldcurve.i
>>> (look at the bottom of the file; there's a few examples) and regenerate
>>> the
>>> wrappers.
>>
>>
>>
>> I added this segment in bonds.i:
>>
>>
>>
>> %rename(CallableFixedRateBond) CallableFixedRateBondPtr;
>>
>> class CallableFixedRateBondPtr : public BondPtr {
>>
>>     %feature("kwargs") CallableFixedRateBondPtr;
>>
>>   public:
>>
>>     %extend {
>>
>>         CallableFixedRateBondPtr(
>>
>>                 Integer settlementDays,
>>
>>                 Real faceAmount,
>>
>>                 const Schedule &schedule,
>>
>>                 const std::vector<Rate>& coupons,
>>
>>                 const DayCounter& accrualDayCounter,
>>
>>                 BusinessDayConvention paymentConvention,
>>
>>                 Real redemption,
>>
>>                 Date issueDate,
>>
>>                 const CallabilitySchedule &putCallSchedule) {
>>
>>             return new CallableFixedRateBondPtr(
>>
>>                 new CallableFixedRateBond(settlementDays, faceAmount,
>>
>>                                   schedule, coupons, accrualDayCounter,
>>
>>                                   paymentConvention, redemption,
>>
>>                                   issueDate, putCallSchedule));
>>
>>         }
>>
>>     }
>>
>> };
>>
>>
>>
>> Thanks so much!
>>
>> S
>>
>>
>>
>>
>>
>> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
>> Sent: Monday, December 16, 2013 10:59 AM
>> To: Simon Mazzucca
>> Subject: Re: Adding functions to QuantLib SWIG
>>
>>
>>
>> Hi,
>>     I'm not sure what samples you're referring to? Anyway, I can have
>> a look at your SWIG interface if you post it here.
>>
>> Luigi
>>
>>
>> On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:
>>
>>
>>> I am also trying to convert CallableFixedRateBond using SWIG.
>>>
>>> I made some progress by copying the FixedRateBond segment in bonds.i, but
>>> at
>>> the end of the day I'm getting errors when trying to compile.
>>>
>>> Where exactly are the samples ? I don't see them anywhere ?
>>>
>>> Thank you,
>>> Simon
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
>>> http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>> organizations don't have a clear picture of how application performance
>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>> your
>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>>> Pro!
>>>
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html
>>
>> To unsubscribe from Adding functions to QuantLib SWIG, click here.
>> NAML
>>
>>
>>
>>
>>
>> This e-mail, including its contents and attachments, if any, is
>> confidential
>> and is intended only for the addressee. If you are not the intended
>> recipient, you are hereby notified that any use, dissemination or
>> distribution of this communication is strictly forbidden. If you received
>> this e-mail in error please immediately notify the sender and delete or
>> destroy this and all copies of this message and all attachments. Any
>> unauthorized disclosure, use, distribution, or reproduction of this
>> message
>> or any attachments is prohibited and may be unlawful.
>>
>>
>> ________________________________
>> View this message in context: RE: Adding functions to QuantLib SWIG
>>
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14746.html
>
> To unsubscribe from Adding functions to QuantLib SWIG, click here.
> NAML
>
>
>
>
>
> This e-mail, including its contents and attachments, if any, is confidential
> and is intended only for the addressee. If you are not the intended
> recipient, you are hereby notified that any use, dissemination or
> distribution of this communication is strictly forbidden. If you received
> this e-mail in error please immediately notify the sender and delete or
> destroy this and all copies of this message and all attachments. Any
> unauthorized disclosure, use, distribution, or reproduction of this message
> or any attachments is prohibited and may be unlawful.
>
>
> ________________________________
> View this message in context: RE: Adding functions to QuantLib SWIG
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>




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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
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/Adding-functions-to-QuantLib-SWIG-tp6140p14748.html

To unsubscribe from Adding functions to QuantLib SWIG, click here.
NAML





This e-mail, including its contents and attachments, if any, is confidential and is intended only for the addressee. If you are not the intended recipient, you are hereby notified that any use, dissemination or distribution of this communication is strictly forbidden. If you received this e-mail in error please immediately notify the sender and delete or destroy this and all copies of this message and all attachments. Any unauthorized disclosure, use, distribution, or reproduction of this message or any attachments is prohibited and may be unlawful.

Reply | Threaded
Open this post in threaded view
|

Re: Adding functions to QuantLib SWIG

Luigi Ballabio
That's weird. The file I'm attaching worked for me (the wrappers
compiled cleanly). I'm on a Linux machine, but that shouldn't
matter...

Luigi


On Mon, Dec 16, 2013 at 5:48 PM, smazzucca <[hidden email]> wrote:

> Sorry, no luck. Same exact result.
>
>
>
> Simon
>
>
>
> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
> Sent: Monday, December 16, 2013 11:46 AM
>
>
> To: Simon Mazzucca
> Subject: Re: Adding functions to QuantLib SWIG
>
>
>
> Ok, try adding
>
>
> %include callability.i
>
> at the beginning.
>
> Luigi
>
>
> On Mon, Dec 16, 2013 at 5:39 PM, smazzucca <[hidden email]> wrote:
>
>
>> Sorry, I did have those declarations at the top. But when I build the c
>> wrapper (NQuantLibc) I get 3 errors and 1 warning:
>>
>>
>>
>> error C2061: syntax error : identifier 'CallabilitySchedule'
>>
>> ...\csharp\cpp\quantlib_wrap.cpp
>>
>> Line: 5575
>>
>>
>>
>> error C2065: 'putCallSchedule' : undeclared identifier
>>
>> ...\csharp\cpp\quantlib_wrap.cpp
>>
>> Line: 5580
>>
>>
>>
>> error C2660: 'new_CallableFixedRateBondPtr' : function does not take 9
>> arguments
>>
>> ...\csharp\cpp\quantlib_wrap.cpp
>>
>> Line: 78439
>>
>>
>>
>> warning C4005: 'SWIGSTDCALL' : macro redefinition
>>
>> ...\csharp\cpp\quantlib_wrap.cpp
>>
>> Line: 339
>>
>>
>>
>> The first 2 error point here:
>>
>>
>>
>> SWIGINTERN CallableFixedRateBondPtr *new_CallableFixedRateBondPtr(Integer
>> settlementDays,Real faceAmount,Schedule const &schedule,std::vector< Rate
>> >
>> const &coupons,DayCounter const &accrualDayCounter,BusinessDayConvention
>> paymentConvention,Real redemption,Date issueDate,CallabilitySchedule const
>> &putCallSchedule){
>>
>>             return new CallableFixedRateBondPtr(
>>
>>                 new CallableFixedRateBond(settlementDays, faceAmount,
>>
>>                                   schedule, coupons, accrualDayCounter,
>>
>>                                   paymentConvention, redemption,
>>
>>                                   issueDate, putCallSchedule));
>>
>>
>>
>>
>>
>>
>>
>> The third one here:
>>
>>
>>
>>       result = (CallableFixedRateBondPtr
>> *)new_CallableFixedRateBondPtr(arg1,arg2,(Schedule const
>> &)*arg3,(std::vector< double > const &)*arg4,(DayCounter const
>> &)*arg5,arg6,arg7,arg8,(CallabilitySchedule const &)*arg9);
>>
>>
>>
>> Simon
>>
>>
>>
>> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
>> Sent: Monday, December 16, 2013 11:26 AM
>>
>>
>> To: Simon Mazzucca
>> Subject: Re: Adding functions to QuantLib SWIG
>>
>>
>>
>> I see. The examples are the ones commented at the end of the file:
>>
>>
>> // combine traits as you wish, e.g.,
>> // export_piecewise_curve(PiecewiseLinearForward,ForwardRate,Linear);
>> // export_piecewise_curve(PiecewiseLinearZero,ZeroYield,Linear);
>> // export_piecewise_curve(PiecewiseCubicZero,ZeroYield,Cubic);
>>
>> As for your callable-bond wrapper, it looks correct, but I think you
>> also have to add
>>
>> using QuantLib::CallableFixedRateBond;
>>
>> and
>>
>> typedef boost::shared_ptr<Instrument> CallableFixedRateBondPtr;
>>
>> among the other similar declarations at the beginning of bonds.i
>> (they're part of a scheme to hide shared_ptr, which are not idiomatic
>> in the languages we're exporting to).
>>
>> Luigi
>>
>>
>>
>> On Mon, Dec 16, 2013 at 5:07 PM, smazzucca <[hidden email]> wrote:
>>
>>
>>> I was referring to this, previously in the same thread:
>>>
>>>
>>>
>>>>If you want more combinations, you have to modify piecewiseyieldcurve.i
>>>> (look at the bottom of the file; there's a few examples) and regenerate
>>>> the
>>>> wrappers.
>>>
>>>
>>>
>>> I added this segment in bonds.i:
>>>
>>>
>>>
>>> %rename(CallableFixedRateBond) CallableFixedRateBondPtr;
>>>
>>> class CallableFixedRateBondPtr : public BondPtr {
>>>
>>>     %feature("kwargs") CallableFixedRateBondPtr;
>>>
>>>   public:
>>>
>>>     %extend {
>>>
>>>         CallableFixedRateBondPtr(
>>>
>>>                 Integer settlementDays,
>>>
>>>                 Real faceAmount,
>>>
>>>                 const Schedule &schedule,
>>>
>>>                 const std::vector<Rate>& coupons,
>>>
>>>                 const DayCounter& accrualDayCounter,
>>>
>>>                 BusinessDayConvention paymentConvention,
>>>
>>>                 Real redemption,
>>>
>>>                 Date issueDate,
>>>
>>>                 const CallabilitySchedule &putCallSchedule) {
>>>
>>>             return new CallableFixedRateBondPtr(
>>>
>>>                 new CallableFixedRateBond(settlementDays, faceAmount,
>>>
>>>                                   schedule, coupons, accrualDayCounter,
>>>
>>>                                   paymentConvention, redemption,
>>>
>>>                                   issueDate, putCallSchedule));
>>>
>>>         }
>>>
>>>     }
>>>
>>> };
>>>
>>>
>>>
>>> Thanks so much!
>>>
>>> S
>>>
>>>
>>>
>>>
>>>
>>> From: Luigi Ballabio [via QuantLib] [mailto:ml-node+[hidden email]]
>>> Sent: Monday, December 16, 2013 10:59 AM
>>> To: Simon Mazzucca
>>> Subject: Re: Adding functions to QuantLib SWIG
>>>
>>>
>>>
>>> Hi,
>>>     I'm not sure what samples you're referring to? Anyway, I can have
>>> a look at your SWIG interface if you post it here.
>>>
>>> Luigi
>>>
>>>
>>> On Fri, Dec 13, 2013 at 8:57 PM, smazzucca <[hidden email]> wrote:
>>>
>>>
>>>> I am also trying to convert CallableFixedRateBond using SWIG.
>>>>
>>>> I made some progress by copying the FixedRateBond segment in bonds.i,
>>>> but
>>>> at
>>>> the end of the day I'm getting errors when trying to compile.
>>>>
>>>> Where exactly are the samples ? I don't see them anywhere ?
>>>>
>>>> Thank you,
>>>> Simon
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>>
>>>> http://quantlib.10058.n7.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p14737.html
>>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>>> organizations don't have a clear picture of how application performance
>>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>>> your
>>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of
>>>> AppDynamics
>>>> Pro!
>>>>
>>>>
>>>>
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> QuantLib-users mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>>
>>>
>>>
>>> --
>>> <https://implementingquantlib.blogspot.com>
>>> <https://twitter.com/lballabio>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>> organizations don't have a clear picture of how application performance
>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>> your
>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>>> Pro!
>>>
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14741.html
>>>
>>> To unsubscribe from Adding functions to QuantLib SWIG, click here.
>>> NAML
>>>
>>>
>>>
>>>
>>>
>>> This e-mail, including its contents and attachments, if any, is
>>> confidential
>>> and is intended only for the addressee. If you are not the intended
>>> recipient, you are hereby notified that any use, dissemination or
>>> distribution of this communication is strictly forbidden. If you received
>>> this e-mail in error please immediately notify the sender and delete or
>>> destroy this and all copies of this message and all attachments. Any
>>> unauthorized disclosure, use, distribution, or reproduction of this
>>> message
>>> or any attachments is prohibited and may be unlawful.
>>>
>>>
>>> ________________________________
>>> View this message in context: RE: Adding functions to QuantLib SWIG
>>>
>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Rapidly troubleshoot problems before they affect your business. Most IT
>>> organizations don't have a clear picture of how application performance
>>> affects their revenue. With AppDynamics, you get 100% visibility into
>>> your
>>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>>> Pro!
>>>
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14746.html
>>
>> To unsubscribe from Adding functions to QuantLib SWIG, click here.
>> NAML
>>
>>
>>
>>
>>
>> This e-mail, including its contents and attachments, if any, is
>> confidential
>> and is intended only for the addressee. If you are not the intended
>> recipient, you are hereby notified that any use, dissemination or
>> distribution of this communication is strictly forbidden. If you received
>> this e-mail in error please immediately notify the sender and delete or
>> destroy this and all copies of this message and all attachments. Any
>> unauthorized disclosure, use, distribution, or reproduction of this
>> message
>> or any attachments is prohibited and may be unlawful.
>>
>>
>> ________________________________
>> View this message in context: RE: Adding functions to QuantLib SWIG
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
>
>
>
> --
> <https://implementingquantlib.blogspot.com>
> <https://twitter.com/lballabio>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> 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/Adding-functions-to-QuantLib-SWIG-tp6140p14748.html
>
> To unsubscribe from Adding functions to QuantLib SWIG, click here.
> NAML
>
>
>
>
>
> This e-mail, including its contents and attachments, if any, is confidential
> and is intended only for the addressee. If you are not the intended
> recipient, you are hereby notified that any use, dissemination or
> distribution of this communication is strictly forbidden. If you received
> this e-mail in error please immediately notify the sender and delete or
> destroy this and all copies of this message and all attachments. Any
> unauthorized disclosure, use, distribution, or reproduction of this message
> or any attachments is prohibited and may be unlawful.
>
>
> ________________________________
> View this message in context: RE: Adding functions to QuantLib SWIG
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


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

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

bonds.i (19K) Download Attachment
12