QuantLib Java

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

QuantLib Java

John Nichol-2
Hi,

QuantLib looks very interesting, great work! I am new to QuantLib and
SWIG so apologies if I am asking stupid or inappropriate questions, have
spent many hours searching and building and googling to get to where I
am now!

I have followed Jonah Witters thread "Quantlib available from Java +
using Eclipse as IDE for building quantlib" and followed though his
tutorial as best I can with the 0.3.10 version of QuantLib + some
downloads from CVS.

I have a few questions that I would appreciate some input on
1) When is 0.3.11 likely to be released? I understand this is the first
release expected to have the undated Swig interfaces.
2) Is there is a CVS tag or version of the Swig files for Java that work
with the 0.3.10 release, basically  a bundle of the changes Jonah made?
3) Looking at the latest files in CVS it seems there is still a
functionality missing from the Swig files. E.g. bond.i does not expose
several important methods like

        const std::vector<boost::shared_ptr<CashFlow> >& cashflows() const;
        const boost::shared_ptr<CashFlow>& redemption() const;
        const Calendar& calendar() const;
        BusinessDayConvention businessDayConvention() const;
        const DayCounter& dayCounter() const;
        Frequency frequency() const;

Is this because SWIG does not support exposing this functionality (I
will ask this on the SWIG list), or simply because no one has needed to
expose this functionality yet?

I had a go at making redemption() available in the bond.i file but
wasn't able to get access to the CashFlow object in a useful way. I
could get a SWIGTYPE_p_CashFlow java object, but I can't see how one
uses that. My C++ is very very rusty so I am probably just being a muppet!

Thanks,

John




Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Java

johan-35
Hi,

some quick answers to your questions:
1) When is 0.3.11 likely to be released? I don't know, that's up to quantlib.org. I understand this is the first release expected to have the undated Swig interfaces: That is correct.
2) Is there is a CVS tag or version of the Swig files for Java that work
with the 0.3.10 release, basically  a bundle of the changes Jonah made? I don't think so... why not download quantlib from the cvs and download 0.3.11 version of quantlib AND swig interface files?
3) Indeed, simply because no one has needed to expose this functionality yet!

regards,
Johan Witters

>-----Original Message-----
>From: John Nichol [mailto:[hidden email]]
>Sent: Wednesday, August 31, 2005 02:22 PM
>To: [hidden email]
>Subject: [Quantlib-users] QuantLib Java
>
>Hi,
>
>QuantLib looks very interesting, great work! I am new to QuantLib and
>SWIG so apologies if I am asking stupid or inappropriate questions, have
>spent many hours searching and building and googling to get to where I
>am now!
>
>I have followed Jonah Witters thread "Quantlib available from Java +
>using Eclipse as IDE for building quantlib" and followed though his
>tutorial as best I can with the 0.3.10 version of QuantLib + some
>downloads from CVS.
>
>I have a few questions that I would appreciate some input on
>1) When is 0.3.11 likely to be released? I understand this is the first
>release expected to have the undated Swig interfaces.
>2) Is there is a CVS tag or version of the Swig files for Java that work
>with the 0.3.10 release, basically  a bundle of the changes Jonah made?
>3) Looking at the latest files in CVS it seems there is still a
>functionality missing from the Swig files. E.g. bond.i does not expose
>several important methods like
>
>        const std::vector<boost::shared_ptr<CashFlow> >& cashflows() const;
>        const boost::shared_ptr<CashFlow>& redemption() const;
>        const Calendar& calendar() const;
>        BusinessDayConvention businessDayConvention() const;
>        const DayCounter& dayCounter() const;
>        Frequency frequency() const;
>
>Is this because SWIG does not support exposing this functionality (I
>will ask this on the SWIG list), or simply because no one has needed to
>expose this functionality yet?
>
>I had a go at making redemption() available in the bond.i file but
>wasn't able to get access to the CashFlow object in a useful way. I
>could get a SWIGTYPE_p_CashFlow java object, but I can't see how one
>uses that. My C++ is very very rusty so I am probably just being a muppet!
>
>Thanks,
>
>John
>
>
>
>
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Java

johan-35
In reply to this post by John Nichol-2
Hi,

some quick answers to your questions:
1) When is 0.3.11 likely to be released? I don't know, that's up to quantlib.org. I understand this is the first release expected to have the undated Swig interfaces: That is correct.
2) Is there is a CVS tag or version of the Swig files for Java that work
with the 0.3.10 release, basically  a bundle of the changes Jonah made? I don't think so... why not download quantlib from the cvs and download 0.3.11 version of quantlib AND swig interface files?
3) Indeed, simply because no one has needed to expose this functionality yet!

regards,
Johan Witters

>-----Original Message-----
>From: John Nichol [mailto:[hidden email]]
>Sent: Wednesday, August 31, 2005 02:22 PM
>To: [hidden email]
>Subject: [Quantlib-users] QuantLib Java
>
>Hi,
>
>QuantLib looks very interesting, great work! I am new to QuantLib and
>SWIG so apologies if I am asking stupid or inappropriate questions, have
>spent many hours searching and building and googling to get to where I
>am now!
>
>I have followed Jonah Witters thread "Quantlib available from Java +
>using Eclipse as IDE for building quantlib" and followed though his
>tutorial as best I can with the 0.3.10 version of QuantLib + some
>downloads from CVS.
>
>I have a few questions that I would appreciate some input on
>1) When is 0.3.11 likely to be released? I understand this is the first
>release expected to have the undated Swig interfaces.
>2) Is there is a CVS tag or version of the Swig files for Java that work
>with the 0.3.10 release, basically  a bundle of the changes Jonah made?
>3) Looking at the latest files in CVS it seems there is still a
>functionality missing from the Swig files. E.g. bond.i does not expose
>several important methods like
>
>        const std::vector<boost::shared_ptr<CashFlow> >& cashflows() const;
>        const boost::shared_ptr<CashFlow>& redemption() const;
>        const Calendar& calendar() const;
>        BusinessDayConvention businessDayConvention() const;
>        const DayCounter& dayCounter() const;
>        Frequency frequency() const;
>
>Is this because SWIG does not support exposing this functionality (I
>will ask this on the SWIG list), or simply because no one has needed to
>expose this functionality yet?
>
>I had a go at making redemption() available in the bond.i file but
>wasn't able to get access to the CashFlow object in a useful way. I
>could get a SWIGTYPE_p_CashFlow java object, but I can't see how one
>uses that. My C++ is very very rusty so I am probably just being a muppet!
>
>Thanks,
>
>John
>
>
>
>
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Java

John Nichol-2
In reply to this post by johan-35
Johan,

Re 2) I tried downloading the latest HEAD from CVS but it wasn't building at the time I tried. I will try again when I have some spare time.
Re 3) I persevered and managed to get the functionallity I wanted exposed through SWIG. All I have had to update is the .i files. If anyone is interested I am happy to contribute them back, frankly I have done nothing other than follow the patterns you introduced. My area of interest at the moment is bond based pricing and so the changes are mainly exposing relevant enumerations and methods to access the bond cashflows to do duration and convexity calculations.

Finally I have never actually managed to get things building as cleanly as I would like with the 0.3.10 version of QuantLib. The C++ and Java generated by SWIG both need minor tweeks to get them working correctly. Its limited to 4 C++ methods (not in areas I have touched) and one Java method. Did you have to make minor Java/C++ generated code tweeks to get the code to compile?

The specific problems were
1) quantlib.cxx - the following generated method will not compile


//JNIEXPORT jlong JNICALL Java_org_quantlib_quantlibJNI_SWIGTimeGridUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
//    jlong baseptr = 0;
//    (void)jenv;
//    (void)jcls;
//    *(std::vector<double > **)(void *)&baseptr = *(TimeGrid **)(void *)&jarg1;
//    return baseptr;
//}

//JNIEXPORT jlong JNICALL Java_org_quantlib_quantlibJNI_SWIGStochasticProcess1DUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
//    jlong baseptr = 0;
//    (void)jenv;
//    (void)jcls;
//    *(boost::shared_ptr<GenericStochasticProcess > **)(void *)&baseptr = *(StochasticProcess1DPtr **)(void *)&jarg1;
//    return baseptr;
//}
//
//JNIEXPORT jlong JNICALL Java_org_quantlib_quantlibJNI_SWIGBlackScholesProcessUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
//    jlong baseptr = 0;
//    (void)jenv;
//    (void)jcls;
//    *(StochasticProcess1DPtr **)(void *)&baseptr = *(BlackScholesProcessPtr **)(void *)&jarg1;
//    return baseptr;
//}
//
//JNIEXPORT jlong JNICALL Java_org_quantlib_quantlibJNI_SWIGMerton76ProcessUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
//    jlong baseptr = 0;
//    (void)jenv;
//    (void)jcls;
//    *(StochasticProcess1DPtr **)(void *)&baseptr = *(Merton76ProcessPtr **)(void *)&jarg1;
//    return baseptr;
//}

2) In TimeGrid.java the size method would not compile until I changed it to
  public long size() {
    return quantlibJNI.TimeGrid_size(swigCPtr);
  }

All of these problems were building 0.3.10 quantlib  *.i files. It may be that these are some of the corrections you have already made!

Regards,

John



[hidden email] wrote:
Hi,

some quick answers to your questions:
1) When is 0.3.11 likely to be released? I don't know, that's up to quantlib.org. I understand this is the first release expected to have the undated Swig interfaces: That is correct.
2) Is there is a CVS tag or version of the Swig files for Java that work
with the 0.3.10 release, basically  a bundle of the changes Jonah made? I don't think so... why not download quantlib from the cvs and download 0.3.11 version of quantlib AND swig interface files?
3) Indeed, simply because no one has needed to expose this functionality yet!

regards,
Johan Witters
  
-----Original Message-----
From: John Nichol [[hidden email]]
Sent: Wednesday, August 31, 2005 02:22 PM
To: [hidden email]
Subject: [Quantlib-users] QuantLib Java

Hi,

QuantLib looks very interesting, great work! I am new to QuantLib and
SWIG so apologies if I am asking stupid or inappropriate questions, have
spent many hours searching and building and googling to get to where I
am now!

I have followed Jonah Witters thread "Quantlib available from Java +
using Eclipse as IDE for building quantlib" and followed though his
tutorial as best I can with the 0.3.10 version of QuantLib + some
downloads from CVS.

I have a few questions that I would appreciate some input on
1) When is 0.3.11 likely to be released? I understand this is the first
release expected to have the undated Swig interfaces.
2) Is there is a CVS tag or version of the Swig files for Java that work
with the 0.3.10 release, basically  a bundle of the changes Jonah made?
3) Looking at the latest files in CVS it seems there is still a
functionality missing from the Swig files. E.g. bond.i does not expose
several important methods like

       const std::vector<boost::shared_ptr<CashFlow> >& cashflows() const;
       const boost::shared_ptr<CashFlow>& redemption() const;
       const Calendar& calendar() const;
       BusinessDayConvention businessDayConvention() const;
       const DayCounter& dayCounter() const;
       Frequency frequency() const;

Is this because SWIG does not support exposing this functionality (I
will ask this on the SWIG list), or simply because no one has needed to
expose this functionality yet?

I had a go at making redemption() available in the bond.i file but
wasn't able to get access to the CashFlow object in a useful way. I
could get a SWIGTYPE_p_CashFlow java object, but I can't see how one
uses that. My C++ is very very rusty so I am probably just being a muppet!

Thanks,

John







    




  
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Java

johan-35
In reply to this post by John Nichol-2
Hi John,

2) I have done this a couple of weeks before and it did build without errors. Can anybody say what label is a stable (0.3.11) development version of quantlib?
3) I would like to include these updates. However, I have no write-access CVS. Can you post them to the quantlib-usersgroup... I guess someone of quantlib.org will do this.

Finally... I did not have any errors with the generate java or c++ code and so I didn't need to make any change to the code. I'm pretty sure that using stable version of quantlib and using the same version of the swig interface should do the trick. Hopefully the 0.3.11 version will soon be production stable.

regards,

Johan

>-----Original Message-----
>From: John Nichol [mailto:[hidden email]]
>Sent: Saturday, September 3, 2005 01:07 PM
>To: [hidden email]
>Cc: [hidden email]
>Subject: Re: [Quantlib-users] QuantLib Java
>
>Johan,
>
>Re 2) I tried downloading the latest HEAD from CVS but it wasn't
>building at the time I tried. I will try again when I have some spare time.
>Re 3) I persevered and managed to get the functionallity I wanted
>exposed through SWIG. All I have had to update is the .i files. If
>anyone is interested I am happy to contribute them back, frankly I have
>done nothing other than follow the patterns you introduced. My area of
>interest at the moment is bond based pricing and so the changes are
>mainly exposing relevant enumerations and methods to access the bond
>cashflows to do duration and convexity calculations.
>
>Finally I have never actually managed to get things building as cleanly
>as I would like with the 0.3.10 version of QuantLib. The C++ and Java
>generated by SWIG both need minor tweeks to get them working correctly.
>Its limited to 4 C++ methods (not in areas I have touched) and one Java
>method. Did you have to make minor Java/C++ generated code tweeks to get
>the code to compile?
>
>The specific problems were
>1) quantlib.cxx - the following generated method will not compile
>
>
>//JNIEXPORT jlong JNICALL
>Java_org_quantlib_quantlibJNI_SWIGTimeGridUpcast(JNIEnv *jenv, jclass
>jcls, jlong jarg1) {
>//    jlong baseptr = 0;
>//    (void)jenv;
>//    (void)jcls;
>//    *(std::vector<double > **)(void *)&baseptr = *(TimeGrid **)(void
>*)&jarg1;
>//    return baseptr;
>//}
>
>//JNIEXPORT jlong JNICALL
>Java_org_quantlib_quantlibJNI_SWIGStochasticProcess1DUpcast(JNIEnv
>*jenv, jclass jcls, jlong jarg1) {
>//    jlong baseptr = 0;
>//    (void)jenv;
>//    (void)jcls;
>//    *(boost::shared_ptr<GenericStochasticProcess > **)(void *)&baseptr
>= *(StochasticProcess1DPtr **)(void *)&jarg1;
>//    return baseptr;
>//}
>//
>//JNIEXPORT jlong JNICALL
>Java_org_quantlib_quantlibJNI_SWIGBlackScholesProcessUpcast(JNIEnv
>*jenv, jclass jcls, jlong jarg1) {
>//    jlong baseptr = 0;
>//    (void)jenv;
>//    (void)jcls;
>//    *(StochasticProcess1DPtr **)(void *)&baseptr =
>*(BlackScholesProcessPtr **)(void *)&jarg1;
>//    return baseptr;
>//}
>//
>//JNIEXPORT jlong JNICALL
>Java_org_quantlib_quantlibJNI_SWIGMerton76ProcessUpcast(JNIEnv *jenv,
>jclass jcls, jlong jarg1) {
>//    jlong baseptr = 0;
>//    (void)jenv;
>//    (void)jcls;
>//    *(StochasticProcess1DPtr **)(void *)&baseptr =
>*(Merton76ProcessPtr **)(void *)&jarg1;
>//    return baseptr;
>//}
>
>2) In TimeGrid.java the size method would not compile until I changed it to
>  public long size() {
>    return quantlibJNI.TimeGrid_size(swigCPtr);
>  }
>
>All of these problems were building 0.3.10 quantlib  *.i files. It may
>be that these are some of the corrections you have already made!
>
>Regards,
>
>John
>
>
>
>[hidden email] wrote:
>
>>Hi,
>>
>>some quick answers to your questions:
>>1) When is 0.3.11 likely to be released? I don't know, that's up to quantlib.org. I understand this is the first release expected to have the undated Swig interfaces: That is correct.
>>2) Is there is a CVS tag or version of the Swig files for Java that work
>>with the 0.3.10 release, basically  a bundle of the changes Jonah made? I don't think so... why not download quantlib from the cvs and download 0.3.11 version of quantlib AND swig interface files?
>>3) Indeed, simply because no one has needed to expose this functionality yet!
>>
>>regards,
>>Johan Witters
>>
>>
>>>-----Original Message-----
>>>From: John Nichol [mailto:[hidden email]]
>>>Sent: Wednesday, August 31, 2005 02:22 PM
>>>To: [hidden email]
>>>Subject: [Quantlib-users] QuantLib Java
>>>
>>>Hi,
>>>
>>>QuantLib looks very interesting, great work! I am new to QuantLib and
>>>SWIG so apologies if I am asking stupid or inappropriate questions, have
>>>spent many hours searching and building and googling to get to where I
>>>am now!
>>>
>>>I have followed Jonah Witters thread "Quantlib available from Java +
>>>using Eclipse as IDE for building quantlib" and followed though his
>>>tutorial as best I can with the 0.3.10 version of QuantLib + some
>>>downloads from CVS.
>>>
>>>I have a few questions that I would appreciate some input on
>>>1) When is 0.3.11 likely to be released? I understand this is the first
>>>release expected to have the undated Swig interfaces.
>>>2) Is there is a CVS tag or version of the Swig files for Java that work
>>>with the 0.3.10 release, basically  a bundle of the changes Jonah made?
>>>3) Looking at the latest files in CVS it seems there is still a
>>>functionality missing from the Swig files. E.g. bond.i does not expose
>>>several important methods like
>>>
>>>       const std::vector<boost::shared_ptr<CashFlow> >& cashflows() const;
>>>       const boost::shared_ptr<CashFlow>& redemption() const;
>>>       const Calendar& calendar() const;
>>>       BusinessDayConvention businessDayConvention() const;
>>>       const DayCounter& dayCounter() const;
>>>       Frequency frequency() const;
>>>
>>>Is this because SWIG does not support exposing this functionality (I
>>>will ask this on the SWIG list), or simply because no one has needed to
>>>expose this functionality yet?
>>>
>>>I had a go at making redemption() available in the bond.i file but
>>>wasn't able to get access to the CashFlow object in a useful way. I
>>>could get a SWIGTYPE_p_CashFlow java object, but I can't see how one
>>>uses that. My C++ is very very rusty so I am probably just being a muppet!
>>>
>>>Thanks,
>>>
>>>John
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>




Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Java

Luigi Ballabio
In reply to this post by John Nichol-2
On 08/31/2005 02:22:06 PM, John Nichol wrote:
> 1) When is 0.3.11 likely to be released? I understand this is the  
> first release expected to have the undated Swig interfaces.

Correct. Probably in a month or two.

> 3) Looking at the latest files in CVS it seems there is still a
> functionality missing from the Swig files. E.g. bond.i does not  
> expose several important methods like
>
>        const std::vector<boost::shared_ptr<CashFlow> >& cashflows()  
> const;
>        const boost::shared_ptr<CashFlow>& redemption() const;
>        const Calendar& calendar() const;
>        BusinessDayConvention businessDayConvention() const;
>        const DayCounter& dayCounter() const;
>        Frequency frequency() const;

I added the methods to the interface--they're available in CVS. I  
couldn't test them with Java, though.

Later,
        Luigi

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

To err is human -- to blame it on a computer is even more so.
-- unknown