Dear Luigi and all, I started using the QuantLib-SWIG-1.4. As I couldn’t find in the examples the implementation of the Bonds example class, I have written my implementation (attached), following the Bonds.cpp in QuantLib-1.4 Examples/Bonds. Nevertheless I have a 0 price for Zero Coupon Bonds and for Floating and an error for the Fixed Rate bonds (more than one instrument with maturity September 12th, 2014. I couldn’t find the PiecewiseYieldCourve as implemented in the c++ class…and I used PiecewiseFlatForward. Any feedback/suggestion, would be appreciated. Kind Regards, Giacomo
------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://www.hpccsystems.com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users Bonds.java (25K) Download Attachment |
Hi Giacomo,
you have to set the evaluation date. After you define todayDate, add Settings.instance().setEvaluationDate(todayDate); otherwise the library will still think it's June 2014. After this, you'll still have errors because you're using some helpers with the same maturity (I didn't have time to check which ones). You'll have to compare your code with the original one and check that you initialize the helpers with the correct arguments. PiecewiseFlatForward should be ok. Hope this helps, Luigi On Mon, Jun 9, 2014 at 10:52 AM, Giacomo Sergio <[hidden email]> wrote: > Dear Luigi and all, > > I started using the QuantLib-SWIG-1.4. As I couldn’t find in the examples > the implementation of the Bonds example class, I have written my > implementation (attached), following the Bonds.cpp in QuantLib-1.4 > Examples/Bonds. Nevertheless I have a 0 price for Zero Coupon Bonds and for > Floating and an error for the Fixed Rate bonds (more than one instrument > with maturity September 12th, 2014. > I couldn’t find the PiecewiseYieldCourve as implemented in the c++ class…and > I used PiecewiseFlatForward. > > Any feedback/suggestion, would be appreciated. > > Kind Regards, > Giacomo > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://www.hpccsystems.com > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://www.hpccsystems.com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
Thank you very much, that was helpful. Attached the new version, hope is useful, without errors. The results still do not match with the cpp version. I¹ll review everything again. If anyone is working on that too and have some hints are welcome. Regards, Giacomo Il giorno 09/06/14 13:09, "Luigi Ballabio" <[hidden email]> ha scritto: >Hi Giacomo, > you have to set the evaluation date. After you define todayDate, add > > Settings.instance().setEvaluationDate(todayDate); > >otherwise the library will still think it's June 2014. > >After this, you'll still have errors because you're using some helpers >with the same maturity (I didn't have time to check which ones). >You'll have to compare your code with the original one and check that >you initialize the helpers with the correct arguments. > >PiecewiseFlatForward should be ok. > >Hope this helps, > Luigi > > > >On Mon, Jun 9, 2014 at 10:52 AM, Giacomo Sergio ><[hidden email]> wrote: >> Dear Luigi and all, >> >> I started using the QuantLib-SWIG-1.4. As I couldn¹t find in the >>examples >> the implementation of the Bonds example class, I have written my >> implementation (attached), following the Bonds.cpp in QuantLib-1.4 >> Examples/Bonds. Nevertheless I have a 0 price for Zero Coupon Bonds and >>for >> Floating and an error for the Fixed Rate bonds (more than one instrument >> with maturity September 12th, 2014. >> I couldn¹t find the PiecewiseYieldCourve as implemented in the c++ >>classand >> I used PiecewiseFlatForward. >> >> Any feedback/suggestion, would be appreciated. >> >> Kind Regards, >> Giacomo >> >> >>------------------------------------------------------------------------- >>----- >> HPCC Systems Open Source Big Data Platform from LexisNexis Risk >>Solutions >> Find What Matters Most in Your Big Data with HPCC Systems >> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. >> Leverages Graph Analysis for Fast Processing & Easy Data Exploration >> http://www.hpccsystems.com >> _______________________________________________ >> QuantLib-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > > > >-- ><https://implementingquantlib.blogspot.com> ><https://twitter.com/lballabio> ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://www.hpccsystems.com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users Bonds.java (28K) Download Attachment |
Hello,
there were a couple of things to fix. One was simple; in the C++ example, when the code said, for instance, vector<Rate> rates(1, 0.05); it doesn't mean a vector with the first element equal to 1 and the second element equal to 0.05; instead, it means a vector of 1 element whose value is 0.05. However, the first coupons of the bonds were in the past so the extra "1" values weren't affecting the price. The actual reason for the different price was unexpected (I never realized it before, but it can happen in C++ too, so thanks for the heads-up). If one says: vector<RelinkableHandle<Quote> > handles(5); what we get is a vector containing 5 copies of the *same* empty handle. But this means that they share the same linked quote, and if we link one of them, all of the others will be linked, too! So a loop like you had in your code, that is, for (i=0; i<5; ++i) handles[i].linkTo(quotes[i]); causes *all* handles to be linked first to quotes[0], then to quotes[1], and eventually to quotes[4]. If you start with an empty vector instead, and add handles as you create them, you'll get the correct results. I'll be happy to add your code to the repository. To whom should I assign the copyright? To you or to your company? Luigi On Mon, Jun 9, 2014 at 3:26 PM, Giacomo Sergio <[hidden email]> wrote: > Hi Luigi, > > Thank you very much, that was helpful. Attached the new version, hope is > useful, without errors. The results still do not match with the cpp > version. I¹ll review everything again. If anyone is working on that too > and have some hints are welcome. > > Regards, > Giacomo > > Il giorno 09/06/14 13:09, "Luigi Ballabio" <[hidden email]> ha > scritto: > >>Hi Giacomo, >> you have to set the evaluation date. After you define todayDate, add >> >> Settings.instance().setEvaluationDate(todayDate); >> >>otherwise the library will still think it's June 2014. >> >>After this, you'll still have errors because you're using some helpers >>with the same maturity (I didn't have time to check which ones). >>You'll have to compare your code with the original one and check that >>you initialize the helpers with the correct arguments. >> >>PiecewiseFlatForward should be ok. >> >>Hope this helps, >> Luigi >> >> >> >>On Mon, Jun 9, 2014 at 10:52 AM, Giacomo Sergio >><[hidden email]> wrote: >>> Dear Luigi and all, >>> >>> I started using the QuantLib-SWIG-1.4. As I couldn¹t find in the >>>examples >>> the implementation of the Bonds example class, I have written my >>> implementation (attached), following the Bonds.cpp in QuantLib-1.4 >>> Examples/Bonds. Nevertheless I have a 0 price for Zero Coupon Bonds and >>>for >>> Floating and an error for the Fixed Rate bonds (more than one instrument >>> with maturity September 12th, 2014. >>> I couldn¹t find the PiecewiseYieldCourve as implemented in the c++ >>>classŠand >>> I used PiecewiseFlatForward. >>> >>> Any feedback/suggestion, would be appreciated. >>> >>> Kind Regards, >>> Giacomo >>> >>> >>>------------------------------------------------------------------------- >>>----- >>> HPCC Systems Open Source Big Data Platform from LexisNexis Risk >>>Solutions >>> Find What Matters Most in Your Big Data with HPCC Systems >>> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. >>> Leverages Graph Analysis for Fast Processing & Easy Data Exploration >>> http://www.hpccsystems.com >>> _______________________________________________ >>> QuantLib-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >> >> >> >>-- >><https://implementingquantlib.blogspot.com> >><https://twitter.com/lballabio> > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |