Hello all,
My name is Matt and I am a new quantlib developer working with the SWIG bindings in Python. I'm trying to expose some additional methods and I admit I'm working a bit blindly as I don't know what I'm doing and I'm relatively unfamiliar with SWIG. In particular, I'd like to expose the fixedSchedule method so that I can get the payment dates out of a VanillaSwap. Here is what I have done to swap.i, first in the header: class VanillaSwapPtr : public SwapPtr { #if defined(SWIGMZSCHEME) || defined(SWIGGUILE) %rename("fair-rate") fairRate; %rename("fair-spread") fairSpread; %rename("fixed-leg-BPS") fixedLegBPS; %rename("floating-leg-BPS") floatingLegBPS; %rename("fixed-schedule") fixedSchedule; #endif and then further down as a method: Schedule fixedSchedule() { return boost::dynamic_pointer_cast<VanillaSwap>(*self) ->fixedSchedule(); } When I do this, it does not compile and something gets all mucked up. I get a bunch of errors that look like these python -c++ -modern -outdir QuantLib \ -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i File "<string>", line 1 ++ ^ SyntaxError: invalid syntax make: [QuantLib/quantlib_wrap.cpp] Error 1 (ignored) python -c++ -modern -outdir QuantLib \ -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i File "<string>", line 1 ++ ^ I'm sure I'm making some incredibly basic mistake - I tried my hardest just to copy what was already there but I must be missing something essential. Is there a good tutorial or example on how to do this? I know there are macros for exposing some other things like curve interpolation quite easily. Is there a similar solution for this? Thanks much and pleased to meet all of you, --Matt ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Matt,
you're not even launching SWIG. The command line should start with: swig -python -c++ -modern ... It looks like the Makefile is not finding SWIG on your machine. Did ./configure find it? May you try running ./configure again and looking at the output? Luigi On Wed, Oct 24, 2012 at 12:24 AM, Matthew Gline <[hidden email]> wrote: > Hello all, > > My name is Matt and I am a new quantlib developer working with the SWIG > bindings in Python. > > I'm trying to expose some additional methods and I admit I'm working a bit > blindly as I don't know what I'm doing and I'm relatively unfamiliar with > SWIG. In particular, I'd like to expose the fixedSchedule method so that I > can get the payment dates out of a VanillaSwap. > > Here is what I have done to swap.i, first in the header: > > class VanillaSwapPtr : public SwapPtr { > #if defined(SWIGMZSCHEME) || defined(SWIGGUILE) > %rename("fair-rate") fairRate; > %rename("fair-spread") fairSpread; > %rename("fixed-leg-BPS") fixedLegBPS; > %rename("floating-leg-BPS") floatingLegBPS; > %rename("fixed-schedule") fixedSchedule; > #endif > > > and then further down as a method: > > Schedule fixedSchedule() { > return boost::dynamic_pointer_cast<VanillaSwap>(*self) > ->fixedSchedule(); > } > > > When I do this, it does not compile and something gets all mucked up. I get > a bunch of errors that look like these > > python -c++ -modern -outdir QuantLib \ > -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i > File "<string>", line 1 > ++ > ^ > SyntaxError: invalid syntax > make: [QuantLib/quantlib_wrap.cpp] Error 1 (ignored) > python -c++ -modern -outdir QuantLib \ > -o QuantLib/quantlib_wrap.cpp ../SWIG/quantlib.i > File "<string>", line 1 > ++ > ^ > > > I'm sure I'm making some incredibly basic mistake - I tried my hardest just > to copy what was already there but I must be missing something essential. > > Is there a good tutorial or example on how to do this? I know there are > macros for exposing some other things like curve interpolation quite easily. > Is there a similar solution for this? > > Thanks much and pleased to meet all of you, > > --Matt > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |