Swig Wrapers for DeltaVolQuote

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

Swig Wrapers for DeltaVolQuote

DPaulino
Could someone please help me with the Swig wrapers for the DeltaVolQuote class?

I tried (and failed):

%{
using QuantLib::DeltaVolQuote;
%}

%ignore DeltaVolQuote;
class DeltaVolQuote : public Quote {};

%template(DeltaVolQuote) boost::shared_ptr<DeltaVolQuote>;
IsObservable(boost::shared_ptr<DeltaVolQuote>);

%{
using QuantLib::DeltaVolQuote;
typedef boost::shared_ptr<DeltaVolQuote> DeltaVolQuotePtr;
%}

%rename(DeltaVolQuote) DeltaVolQuotePtr;
class DeltaVolQuotePtr : public boost::shared_ptr<Quote> {
        public:
                %extend {
                        DeltaVolQuotePtr(Real delta,
                                                 const Handle<Quote>& vol,
                                                 Time maturity,
                                                 DeltaVolQuote::DeltaType deltatype) {
                                        return new  public boost::shared_ptr<DeltaVolQuote>(
                                                new DeltaVolQuote(delta,
                                                                            vol,
                                                                            maturity,
                                                                            deltatype));
                                                                                }

                        DeltaVolQuotePtr(const Handle<Quote>& vol,
                                                         DeltaVolQuote::DeltaType deltatype,
                                                         Time maturity,
                                                         DeltaVolQuote::AtmType atmtype) {

                                        return new  public boost::shared_ptr<DeltaVolQuote>(
                                                new DeltaVolQuote(vol,
                                                                           deltatype,
                                                                           maturity,
                                                                           atmtype));
                                                                                                }
                }
};
Reply | Threaded
Open this post in threaded view
|

Re: Swig Wrapers for DeltaVolQuote

Luigi Ballabio
What's the error with your code?

On Thu, Nov 26, 2015 at 7:16 PM DPaulino <[hidden email]> wrote:
Could someone please help me with the Swig wrapers for the DeltaVolQuote
class?

I tried (and failed):

%{
using QuantLib::DeltaVolQuote;
%}

%ignore DeltaVolQuote;
class DeltaVolQuote : public Quote {};

%template(DeltaVolQuote) boost::shared_ptr<DeltaVolQuote>;
IsObservable(boost::shared_ptr<DeltaVolQuote>);

%{
using QuantLib::DeltaVolQuote;
typedef boost::shared_ptr<DeltaVolQuote> DeltaVolQuotePtr;
%}

%rename(DeltaVolQuote) DeltaVolQuotePtr;
class DeltaVolQuotePtr : public boost::shared_ptr {
        public:
                %extend {
                        DeltaVolQuotePtr(Real delta,
                                                 const Handle& vol,
                                                 Time maturity,
                                                 DeltaVolQuote::DeltaType deltatype) {
                                        return new  public boost::shared_ptr<DeltaVolQuote>(
                                                new DeltaVolQuote(delta,
                                                                            vol,
                                                                            maturity,
                                                                            deltatype));
                                                                                }

                        DeltaVolQuotePtr(const Handle& vol,
                                                         DeltaVolQuote::DeltaType deltatype,
                                                         Time maturity,
                                                         DeltaVolQuote::AtmType atmtype) {

                                        return new  public boost::shared_ptr<DeltaVolQuote>(
                                                new DeltaVolQuote(vol,
                                                                           deltatype,
                                                                           maturity,
                                                                           atmtype));
                                                                                                }
                }
};



--
View this message in context: http://quantlib.10058.n7.nabble.com/Swig-Wrapers-for-DeltaVolQuote-tp17124.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swig Wrapers for DeltaVolQuote

DPaulino
Luigi,

If I try to run swig for C# over this, it complains that DeltaVolQuote is defined multiple times.

If I remove the %rename it compiles for C#, but when I try to write a program using it, I can't pass the DeltaVolQuotePtr to the DeltaVolQuote handles I need for the VannaVolga engine.

Sorry if this a trivial matter, I come from a pure mathematics background and am not familiar with neither swig nor programming in general.
Reply | Threaded
Open this post in threaded view
|

Re: Swig Wrapers for DeltaVolQuote

Luigi Ballabio


On Fri, Nov 27, 2015 at 1:46 PM DPaulino <[hidden email]> wrote: 
If I try to run swig for C# over this, it complains that DeltaVolQuote is
defined multiple times.

Oh yes, there seems to be an incomplete definition already.
 
If I remove the %rename it compiles for C#, but when I try to write a
program using it, I can't pass the DeltaVolQuotePtr to the DeltaVolQuote
handles I need for the VannaVolga engine.

Yes, that's because the definition is incomplete. I'll try and see what's missing.

Later,
    Luigi
 
--

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

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

Re: Swig Wrapers for DeltaVolQuote

DPaulino
Thank you Luigi!
Reply | Threaded
Open this post in threaded view
|

Re: Swig Wrapers for DeltaVolQuote

Luigi Ballabio

On Fri, Nov 27, 2015 at 4:05 PM DPaulino <[hidden email]> wrote:
Thank you Luigi!



--
View this message in context: http://quantlib.10058.n7.nabble.com/Swig-Wrapers-for-DeltaVolQuote-tp17124p17133.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--

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

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

Re: Swig Wrapers for DeltaVolQuote

DPaulino
Sorry Luigi,

with these lines I seem to get the error:

Severity Code Description Project File Line
Error C2512 'QuantLib::DeltaVolQuote::DeltaVolQuote': no appropriate default constructor available NQuantLibc C:\QuantLib-SWIG\CSharp\cpp\quantlib_wrap.cpp 80873

When I go to the refere line what I see is:

SWIGEXPORT void * SWIGSTDCALL CSharp_new__DeltaVolQuote() {
  void * jresult ;
  DeltaVolQuote *result = 0 ;
 
  {
    try {
      result = (DeltaVolQuote *)new DeltaVolQuote();
    } catch (std::out_of_range& e) {
      {
        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
      };
    } catch (std::exception& e) {
      {
        SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
      };
    } catch (...) {
      {
        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
      };
    }
  }
  jresult = (void *)result;
  return jresult;
}

Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Swig Wrapers for DeltaVolQuote

Luigi Ballabio
Right. I hadn't tried Java. Adding https://github.com/lballabio/QuantLib-SWIG/commit/5465db3bf34bcb0600125322495c2d4c528cffc2 should  do the trick.

Luigi


On Tue, Dec 22, 2015 at 5:04 PM DPaulino <[hidden email]> wrote:
Sorry Luigi,

with these lines I seem to get the error:

Severity        Code    Description     Project File    Line
Error   C2512   'QuantLib::DeltaVolQuote::DeltaVolQuote': no appropriate default
constructor available   NQuantLibc
C:\QuantLib-SWIG\CSharp\cpp\quantlib_wrap.cpp   80873

When I go to the refere line what I see is:

SWIGEXPORT void * SWIGSTDCALL CSharp_new__DeltaVolQuote() {
  void * jresult ;
  DeltaVolQuote *result = 0 ;

  {
    try {
      result = (DeltaVolQuote *)new DeltaVolQuote();
    } catch (std::out_of_range& e) {
      {
        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what()));
return 0;
      };
    } catch (std::exception& e) {
      {
        SWIG_CSharpException(SWIG_RuntimeError,
const_cast<char*>(e.what())); return 0;
      };
    } catch (...) {
      {
        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
      };
    }
  }
  jresult = (void *)result;
  return jresult;
}

Any ideas?



--
View this message in context: http://quantlib.10058.n7.nabble.com/Swig-Wrapers-for-DeltaVolQuote-tp17124p17203.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--

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

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

Re: Swig Wrapers for DeltaVolQuote

DPaulino
Thank you Luigi!

I'm actually compiling it for C#, but it worked!

Thank's a lot!