Thank you for your quick reply Alexandre P.
As you suggest dates.end() makes much sense (I pasted the new code below) But I now get the following warning message from the Microsoft Visual C++ runtime Library: Debug Assertion Failed! Program C:\Windows\system32\MSVCP110D.dll File: c:\program files\microsoft visual studio 11.0\vc\include\vector Line: 101 Expression: vector iterator not incrementable For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press Retry to debug the application) My use of the QuantLib::TimeSeries constructor still is not right. I would appreciate any help. Thank you #include<vector> #include<iostream> #include<ql\quantlib.hpp> int main() { std::vector<QuantLib::Date> dates; std::vector<double> quotes; dates.push_back(QuantLib::Date(12, QuantLib::Nov, 2012)); dates.push_back(QuantLib::Date(13, QuantLib::Nov, 2012)); dates.push_back(QuantLib::Date(14, QuantLib::Nov, 2012)); quotes.push_back(40.05); quotes.push_back(40.84); quotes.push_back(41.03); QuantLib::TimeSeries<double> series(dates.begin(), dates.end(), quotes.end()); // Is my time series empty? std::cout << "Is
series empty?\t" << series.empty()
<< std::endl; std::cout << "Value
on November 14th, 2012?\t" <<
series[QuantLib::Date(14, QuantLib::Nov, 2012)] << std::endl; return 0; } // Doesn't work! ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I think he means: QuantLib::TimeSeries<double> series(dates.begin(), dates.end(), quotes.begin()); 发件人: Edouard Tallent [mailto:[hidden email]] Thank you for your quick reply Alexandre P. #include<vector> #include<iostream> #include<ql\quantlib.hpp> int main() { std::vector<QuantLib::Date> dates; std::vector<double> quotes; dates.push_back(QuantLib::Date(12, QuantLib::Nov, 2012)); dates.push_back(QuantLib::Date(13, QuantLib::Nov, 2012)); dates.push_back(QuantLib::Date(14, QuantLib::Nov, 2012)); quotes.push_back(40.05); quotes.push_back(40.84); quotes.push_back(41.03); QuantLib::TimeSeries<double> series(dates.begin(), dates.end(), quotes.end()); // Is my time series empty? std::cout << "Is series empty?\t" << series.empty() << std::endl; std::cout << "Value on November 14th, 2012?\t" << series[QuantLib::Date(14, QuantLib::Nov, 2012)] << std::endl; return 0; } // Doesn't work! ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Guys,
The standard QuantLib TimeSeries class uses a date object as a key. What if I want to also include a timestamp in addition to a date? Is this possible in Quantlib? Thanks, Rob. |
Hello Rob,
currently there's no class in QuantLib providing a timestamp. You'll have to create a structure yourself containing a date and a time, and use that as a key (I think you'll have to implement operator < to make it work). Luigi On Thu, Jul 4, 2013 at 2:42 PM, Rob <[hidden email]> wrote: > Hi Guys, > > The standard QuantLib TimeSeries class uses a date object as a key. What if > I want to also include a timestamp in addition to a date? Is this possible > in Quantlib? > > Thanks, Rob. > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/Re-About-QuantLib-TimeSeries-again-tp14030p14410.html > Sent from the quantlib-users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi, Thanks for the feedback, I found a solution. I created a new version of timeseries.hpp, replacing Date with DateTime, where DateTime is a Boost ptime typedef. Thus, I'm using Boost ptime as the key, which works very nicely since it comes with lots of functionality.
Thanks, Rob. On Sun, Jul 7, 2013 at 7:57 AM, Luigi Ballabio <[hidden email]> wrote: Hello Rob, ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |