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)); } } }; |
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 -- <http://leanpub.com/implementingquantlib> ------------------------------------------------------------------------------ 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 |
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. |
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 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 Yes, that's because the definition is incomplete. I'll try and see what's missing. Later, Luigi -- <http://leanpub.com/implementingquantlib> ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thank you Luigi!
|
The changes at https://github.com/lballabio/QuantLib-SWIG/commit/46a6dc79698e909ca914c172af6c53de12c3f851 should work. Luigi On Fri, Nov 27, 2015 at 4:05 PM DPaulino <[hidden email]> wrote: Thank you Luigi! -- <http://leanpub.com/implementingquantlib> ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
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? |
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, -- <http://leanpub.com/implementingquantlib> ------------------------------------------------------------------------------ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |