C++ Tester 2

#include <iostream>

// Boost

#include <boost/date_time/gregorian/gregorian.hpp>

// Hudson

#include "DayPrice.hpp"

#include "EODDB.hpp"

#include "EODSeries.hpp"

#include "EOWSeries.hpp"

#include "EOMSeries.hpp"

using namespace std;

using namespace Series;

int main()

{

    //std::size_t size;

    //size =EODSeries::load(EODDB::DMYC, "../db/EAFE.csv"); // load all records returned by

    const string name="DJC";

    const string filename="../db/DJC.csv";

    EODDB::DriverType dt=EODDB::YAHOO;

    const boost::gregorian::date begin_date(2008,2,20);

    const boost::gregorian::date end_date(2008,6,20);

    EODDB::instance().load(

                           name,

                           filename,

                           dt,

                           begin_date,

                           end_date

                           );

    const EODSeries& p_eod_series = EODDB::instance().get(name);

    cout << "size()=" << p_eod_series.size() << endl;

    cout << "days()=" << p_eod_series.days() << endl;

    cout << "name()=" << p_eod_series.name() << endl;

    cout << "isLoaded()=" << p_eod_series.isLoaded() << endl;

    cout << "period()=" << p_eod_series.period() << endl;

    //cout << "duration:" << p_eod_series.duration() << endl;

    typedef std::map<boost::gregorian::date, DayPrice> ThisMap;

    ThisMap::const_iterator at=p_eod_series.at_or_before(end_date);

    DayPrice price1=(*at).second;

    cout << "DayPric::key=" << price1.key << endl;

    cout << "DayPric::close=" << price1.close << endl;

    DayPrice price2=p_eod_series.last();

    cout << "DayPric::key=" << price2.key << endl;

    cout << "DayPric::close=" << price2.close << endl;

    ThisMap::const_iterator before=p_eod_series.before(end_date,3);

    DayPrice price3=(*before).second;

    cout << "DayPric::key=" << price3.key << endl;

    cout << "DayPric::close=" << price3.close << endl;

    vector<double> eod_close = p_eod_series.close();

    for(int i=0;i<5;i++)

      cout << eod_close[i] << ",";

    cout << endl;

    const EOWSeries p_eow_series = p_eod_series.weekly();

    cout << "EOW:"<< endl;

    cout << "size()=" << p_eow_series.size() << endl;

    cout << "days()=" << p_eow_series.days() << endl;

    cout << "name()=" << p_eow_series.name() << endl;

    cout << "period()=" << p_eow_series.period() << endl;

    return 0;

}