Hello,
I want to duplicate the derived Eonia OvernightIndex class as a derived FedFunds OvernightIndex class directly by adding one header and one source file (see below) to the <ql/indexes/ibor> QuantLib sub-folder. Additionally, I modified the Makefile.in file to include the two files when building the QuantLib solution (in Visual Studio 11). I can (re)build the solution without any problems, but when I try to use the FedFunds class in Python (after adding to the indexes.i SWIG interface file in a manner similar to the one which allowed me to successfully expose the Sonia class for GBP), I get the error: NameError: name 'FedFunds' is not defined Please note that when the same code with Eonia (instead of FedFunds) works fine (although I need to join the US and European calendars). Any help / suggestions appreciated. Also, if the files below are any good, feel free to use them. Thank you, Ioan
|
Ioan,
may you post the relevant section of the .i file? Thanks, Luigi On Fri, May 30, 2014 at 10:52 PM, Ioan F. <[hidden email]> wrote: > Hello, > > I want to duplicate the derived Eonia OvernightIndex class as a derived > FedFunds OvernightIndex class directly by adding one header and one source > file (see below) to the <ql/indexes/ibor> QuantLib sub-folder. > Additionally, I modified the Makefile.in file to include the two files when > building the QuantLib solution (in Visual Studio 11). > I can (re)build the solution without any problems, but when I try to use the > FedFunds class in Python (after adding to the indexes.i SWIG interface file > in a manner similar to the one which allowed me to successfully expose the > Sonia class for GBP), I get the error: > > NameError: name 'FedFunds' is not defined > > Please note that when the same code with Eonia (instead of FedFunds) works > fine (although I need to join the US and European calendars). > > Any help / suggestions appreciated. > Also, if the files below are any good, feel free to use them. > > Thank you, > Ioan > > > > fedfunds.hpp: > > > > /*! \file fedfunds.hpp > \brief %FedFunds index > */ > > #ifndef quantlib_fedfunds_hpp > #define quantlib_fedfunds_hpp > > #include <ql/indexes/iborindex.hpp> > > namespace QuantLib { > > //! %Fed Funds (for balances held at the Federal Reserve) rate fixed by > the FED. > class FedFunds : public OvernightIndex { > public: > FedFunds(const Handle<YieldTermStructure>& h = > Handle<YieldTermStructure>()); > }; > > } > > #endif > > > > > fedfunds.cpp: > > > > #include <ql/indexes/ibor/fedfunds.hpp> > #include <ql/time/calendars/unitedstates.hpp> > #include <ql/time/daycounters/actual365fixed.hpp> > #include <ql/currencies/america.hpp> > > namespace QuantLib { > > FedFunds::FedFunds(const Handle<YieldTermStructure>& h) > : OvernightIndex("FedFunds", 0, > USDCurrency(), > UnitedStates(UnitedStates::Settlement), > Actual365Fixed(), h) {} > > } > > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-extension-creating-a-FedFunds-derived-class-equivalent-of-Eonia-for-USD-tp15344.html > Sent from the quantlib-dev mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Time is money. Stop wasting it! Get your web API in 5 minutes. > www.restlet.com/download > http://p.sf.net/sfu/restlet > _______________________________________________ > 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/NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi,
Thank you for the reply. Please see the relevant part of the indexes.i interface file below. Also note that the first two "export_quoted_xibor_instance" calls work fine, as I was able to use them in Python (Eonia and Sonia), while the third one (FedFunds) gives me the error. Regards, Ioan // OvernightIndex indexes %{ using QuantLib::OvernightIndex; typedef boost::shared_ptr<Index> OvernightIndexPtr; %} %rename(OvernightIndex) OvernightIndexPtr; class OvernightIndexPtr : public IborIndexPtr { public: %extend { OvernightIndexPtr(const std::string& familyName, Natural settlementDays, const Currency& currency, const Calendar& calendar, const DayCounter& dayCounter, const Handle<YieldTermStructure>& h = Handle<YieldTermStructure>()) { return new OvernightIndexPtr(new OvernightIndex(familyName, settlementDays, currency, calendar, dayCounter, h)); } } }; export_quoted_xibor_instance(Eonia,OvernightIndex); export_quoted_xibor_instance(Sonia,OvernightIndex); export_quotes_xibor_instance(FedFunds,OvernightIndex); |
Hi Ioan,
I kind of hate to say that, but your changes work on my machine. I'm going to commit them to the GitHub repository so that you can check them out and try them. One thing, though: to whom should I assign the copyright at the beginning of the files? Luigi On Thu, Jun 5, 2014 at 5:19 PM, Ioan F. <[hidden email]> wrote: > Hi Luigi, > > Thank you for the reply. Please see the relevant part of the indexes.i > interface file below. > Also note that the first two "export_quoted_xibor_instance" calls work fine, > as I was able to use them in Python (Eonia and Sonia), while the third one > (FedFunds) gives me the error. > > Regards, > Ioan > > > *// OvernightIndex indexes > %{ > using QuantLib::OvernightIndex; > typedef boost::shared_ptr<Index> OvernightIndexPtr; > %} > > %rename(OvernightIndex) OvernightIndexPtr; > > class OvernightIndexPtr : public IborIndexPtr { > public: > %extend { > OvernightIndexPtr(const std::string& familyName, > Natural settlementDays, > const Currency& currency, > const Calendar& calendar, > const DayCounter& dayCounter, > const Handle<YieldTermStructure>& h = > Handle<YieldTermStructure>()) > { > return new OvernightIndexPtr(new > OvernightIndex(familyName, > settlementDays, > currency, > calendar, > dayCounter, h)); > } > } > }; > > export_quoted_xibor_instance(Eonia,OvernightIndex); > export_quoted_xibor_instance(Sonia,OvernightIndex); > export_quotes_xibor_instance(FedFunds,OvernightIndex);* > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-extension-creating-a-FedFunds-derived-class-equivalent-of-Eonia-for-USD-tp15344p15395.html > Sent from the quantlib-dev mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > 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/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/NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Luigi,
I'm glad that the code works. If you really need to provide a copyright name, please feel free to use your name or, if uncomfortable with that, "Anonymous" would work. A link to the GitHub repository would be nice. Thank you, Ioan |
Done. The repo is at <https://github.com/lballabio/quantlib/>.
Luigi On Thu, Jun 5, 2014 at 10:06 PM, Ioan F. <[hidden email]> wrote: > Luigi, > > I'm glad that the code works. > If you really need to provide a copyright name, please feel free to use your > name or, if uncomfortable with that, "Anonymous" would work. > A link to the GitHub repository would be nice. > > Thank you, > Ioan > > > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-extension-creating-a-FedFunds-derived-class-equivalent-of-Eonia-for-USD-tp15344p15398.html > Sent from the quantlib-dev mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > 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/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/NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Luigi,
After testing, it seems that we are not using the correct day count convention when defining the Fed Funds Overnight Index. The change is minimal, and below please see the correct version of the fedfunds.cpp file. If I may suggest so, please update the library to reflect the correction. A quick confirmation message would be highly appreciated (so I know we don't need to worry about it going forward and that will be included in the next official release). Thank you, Ioan fedfunds.cpp: #include <ql/indexes/ibor/fedfunds.hpp> #include <ql/time/calendars/unitedstates.hpp> #include <ql/time/daycounters/actual360.hpp> #include <ql/currencies/america.hpp> namespace QuantLib { FedFunds::FedFunds(const Handle<YieldTermStructure>& h) : OvernightIndex("FedFunds", 0, USDCurrency(), UnitedStates(UnitedStates::Settlement), Actual360(), h) {} } |
Thanks, I've added the correction to the git repository. Luigi On Mon, Mar 16, 2015 at 1:42 PM, Ioan F. <[hidden email]> wrote: Luigi, ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |