Extending SWIG support for InterpolatedZeroCurve

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Extending SWIG support for InterpolatedZeroCurve

grantathon
Hello,

I'm currently using SWIG to access QuantLib via C# and am able to use InterpolatedZeroCurve from QuantLib via ZeroCurve from SWIG.  This class only supports linear interpolation and I need to use cubic, log-cubic, log-linear, foward flat, backward flat, and monotonic.

I looked at the zerocurve.i file and tried creating cubiczerocurve.i, built NQuantLib, and use the package, but I don't see the new class.  I also tried uncommenting the line in zerocurve.i where it reads

export_zero_curve(CubicZeroCurve,Cubic);

However this did nothing after building, etc.  Obviously I'm missing a crucial step somewhere, so if someone could point me in the right direction, we could soon have multiple interpolation types supported via SWIG :)

Grant
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

Luigi Ballabio
Uncommenting the additional export_zero_curve should have worked (and in fact, the whole idea of defining that macro was to make it easier to export more curves). After SWIG runs, is CubicZeroCurve.cs generated in the csharp folder? Is CubicZeroCurve mentioned at all in the generated quantlib_wrap.cpp?

On Fri, Oct 28, 2016 at 10:40 AM grantathon <[hidden email]> wrote:
Hello,

I'm currently using SWIG to access QuantLib via C# and am able to use
InterpolatedZeroCurve from QuantLib via ZeroCurve from SWIG.  This class
only supports linear interpolation and I need to use cubic, log-cubic,
log-linear, foward flat, backward flat, and monotonic.

I looked at the zerocurve.i file and tried creating cubiczerocurve.i, built
NQuantLib, and use the package, but I don't see the new class.  I also tried
uncommenting the line in zerocurve.i where it reads

export_zero_curve(CubicZeroCurve,Cubic);

However this did nothing after building, etc.  Obviously I'm missing a
crucial step somewhere, so if someone could point me in the right direction,
we could soon have multiple interpolation types supported via SWIG :)

Grant



--
View this message in context: http://quantlib.10058.n7.nabble.com/Extending-SWIG-support-for-InterpolatedZeroCurve-tp17827.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

grantathon
I uncommented export_zero_curve(CubicZeroCurve,Cubic), ran the swig.cmd file in QuantLib-SWIG\CSharp, built NQuantLib in Visual Studio, and I still don't see any CubicZeroCurve among the C# classes nor do I see any changes in the quantlib_wrap.cpp.

I guess there is something else I should do other than running the swig.cmd file followed by building NQuantLib in Visual Studio?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

Luigi Ballabio

Hmm. No, you shouldn't do anything else. May you try running the command inside swig.cmd directly? I suspect it might be swallowing an error.


On Sat, Oct 29, 2016, 10:41 grantathon <[hidden email]> wrote:
I uncommented export_zero_curve(CubicZeroCurve,Cubic), ran the swig.cmd file
in QuantLib-SWIG\CSharp, built NQuantLib in Visual Studio, and I still don't
see any CubicZeroCurve among the C# classes nor do I see any changes in the
quantlib_wrap.cpp.

I guess there is something else I should do other than running the swig.cmd
file followed by building NQuantLib in Visual Studio?



--
View this message in context: http://quantlib.10058.n7.nabble.com/Extending-SWIG-support-for-InterpolatedZeroCurve-tp17827p17831.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

grantathon
This post was updated on .
I ran swig.cmd via the command line and realized I wasn't referencing swig.exe properly.  After editing swig.cmd to source swig.exe, I was able to generate LogLinearZeroCurve, CubicZeroCurve, ForwardFlatZeroCurve, BackwardFlatZeroCurve, and MonotonicCubicZeroCurve by adding

export_zero_curve(LogLinearZeroCurve,LogLinear);
export_zero_curve(CubicZeroCurve,Cubic);
export_zero_curve(ForwardFlatZeroCurve,ForwardFlat);
export_zero_curve(BackwardFlatZeroCurve,BackwardFlat);
export_zero_curve(MonotonicCubicZeroCurve,MonotonicCubic);

to zerocurve.i.  I can also use them in my C# applications now!

Unfortunately, I was not successful in generating LogCubicZeroCurve using

export_zero_curve(LogCubicZeroCurve,QuantLib::LogCubic);

nor

export_zero_curve(LogCubicZeroCurve,LogCubic);

due to some build errors in NQuantLibc.  The build errors and output are





Looks like they indicate that there are some private resource (requiredPoints and interpolate) within the LogCubic class.  However, when looking at the QuantLib code, both of those resources are made public (see LogCubic in loginterpolation.hpp).

Any ideas on how to resolve this issue?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

Luigi Ballabio
In SWIG/interpolation.i at line 187, try replacing

    class LogCubic : QuantLib::LogCubic {

with 

    class LogCubic : public QuantLib::LogCubic {

and send me a pull request if that works :)

Luigi


On Fri, Nov 4, 2016 at 9:50 AM grantathon <[hidden email]> wrote:
I ran swig.cmd via the command line and realized I wasn't referencing
swig.exe properly.  After editing swig.cmd to source swig.exe, I was able to
generate LogLinearZeroCurve, CubicZeroCurve, ForwardFlatZeroCurve,
BackwardFlatZeroCurve, and MonotonicCubicZeroCurve by adding

export_zero_curve(LogLinearZeroCurve,LogLinear);
export_zero_curve(CubicZeroCurve,Cubic);
export_zero_curve(ForwardFlatZeroCurve,ForwardFlat);
export_zero_curve(BackwardFlatZeroCurve,BackwardFlat);
export_zero_curve(MonotonicCubicZeroCurve,MonotonicCubic);

to zerocurve.i.

Unfortunately, I was not successful in generating LogCubicZeroCurve using

export_zero_curve(LogCubicZeroCurve,QuantLib::LogCubic);

nor

export_zero_curve(LogCubicZeroCurve,LogCubic);

due to five build errors in NQuantLibc.  The build errors and output are

<http://quantlib.10058.n7.nabble.com/file/n17852/errors.png>

<http://quantlib.10058.n7.nabble.com/file/n17852/outputs.png>

Looks like they indicate that there are some private resource
(requiredPoints and interpolate) within the LogCubic class.  However, when
looking at the QuantLib code, both of those resources are made public (see
LogCubic in loginterpolation.hpp).

Any ideas on how to resolve this issue?



--
View this message in context: http://quantlib.10058.n7.nabble.com/Extending-SWIG-support-for-InterpolatedZeroCurve-tp17827p17852.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extending SWIG support for InterpolatedZeroCurve

grantathon
That worked!  I'll send you a pull request now :)
Loading...