Re: About QuantLib::TimeSeries => SOLUTION

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: About QuantLib::TimeSeries => SOLUTION

tallent_e
Hi again.
I found out a solution.
I am posting my code in case it can help other people.
Below is the code and the output:

#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(QuantLib::Date(12, QuantLib::Nov, 2012), quotes.begin(), 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;

}

 

/* Actual output:

Is series empty?     0

Value on November 14th, 2012?     41.03

*/

 Best,
Édouard

http://quantcorner.wordpress.com/






------------------------------------------------------------------------------
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