Hi all, I'm new to QuantLib and I'm interested to use it for some trading platform development in java. To get familiar with it, I decided to rewrite the example DiscreteHedging.java I used different approach to rewrite this example, by using SWIG director feature to achieve the PathPricer call back function, and use SWIG "boost_shared_ptr.i" to wrap the boost::shared_ptr<> object in MonteCarloModel class. After a few days of trial and error, finally I manage to get my code compile and run correctly. And my code could run a bit faster than the current code in QuantLib-SWIG-1.4/Java/examples/DiscreteHedging.java. In my old laptop, it took 44sec to complete in the current code, but 28sec in my code. I'd like to post my code for sharing, and see if any interest to use it in the next release version of QuantLib-SWIG. BTW how could I share my code, is it simply attaching the code by email? Thanks, QuantLib is a great project. Felix ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Felix,
posting the code here would work, but if you're familiar with GitHub it's more convenient to send me a pull request. Later, Luigi On Tue, Mar 11, 2014 at 5:32 PM, Felix Lee <[hidden email]> wrote: > Hi all, > > I'm new to QuantLib and I'm interested to use it for some trading platform > development in java. > > To get familiar with it, I decided to rewrite the example > DiscreteHedging.java > > I used different approach to rewrite this example, by using SWIG director > feature to achieve the PathPricer call back function, and use SWIG > "boost_shared_ptr.i" to wrap the boost::shared_ptr<> object in > MonteCarloModel class. > > After a few days of trial and error, finally I manage to get my code compile > and run correctly. And my code could run a bit faster than the current code > in QuantLib-SWIG-1.4/Java/examples/DiscreteHedging.java. In my old laptop, > it took 44sec to complete in the current code, but 28sec in my code. > > I'd like to post my code for sharing, and see if any interest to use it in > the next release version of QuantLib-SWIG. > > BTW how could I share my code, is it simply attaching the code by email? > > Thanks, QuantLib is a great project. > > > Felix > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi, OK let me attach the code first and then send you the pull request later. I've also modified the following SWIG interface files to support my java code: 1. quantlib.i: add (directors="1") to enable the directors feature 2. randomnumbers.i: add PseudoRandomMT class 3. montecarlo.i: add PathGeneratorPseudoRandom, PathPricerPath and MonteCarloModelSingleVariatePseudoRandom classes BTW, I added "%include <boost_shared_ptr.i>" into montecarlo.i, but then a warning pop out when generating swig wrapper because the name "shared_ptr" crashes with the one defined in "common.i". Anyway it won't affect the compilation. Felix From: Luigi Ballabio <[hidden email]> To: Felix Lee <[hidden email]> Cc: "[hidden email]" <[hidden email]> Sent: Wednesday, March 12, 2014 6:27 PM Subject: Re: [Quantlib-dev] Rewrite DiscreteHedging.java Hi Felix, posting the code here would work, but if you're familiar with GitHub it's more convenient to send me a pull request. Later, Luigi On Tue, Mar 11, 2014 at 5:32 PM, Felix Lee <[hidden email]> wrote: > Hi all, > > I'm new to QuantLib and I'm interested to use it for some trading platform > development in java. > > To get familiar with it, I decided to rewrite the example > DiscreteHedging.java > > I used different approach to rewrite this example, by using SWIG director > feature to achieve the PathPricer call back function, and use SWIG > "boost_shared_ptr.i" to wrap the boost::shared_ptr<> object in > MonteCarloModel class. > > After a few days of trial and error, finally I manage to get my code compile > and run correctly. And my code could run a bit faster than the current code > in QuantLib-SWIG-1.4/Java/examples/DiscreteHedging.java. In my old laptop, > it took 44sec to complete in the current code, but 28sec in my code. > > I'd like to post my code for sharing, and see if any interest to use it in > the next release version of QuantLib-SWIG. > > BTW how could I share my code, is it simply attaching the code by email? > > Thanks, QuantLib is a great project. > > > Felix > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio > ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev DiscreteHedging.java (17K) Download Attachment quantlib.i (3K) Download Attachment randomnumbers.i (12K) Download Attachment montecarlo.i (18K) Download Attachment |
Free forum by Nabble | Edit this page |