1 /**
2 *  Copyright Mikael H�gdahl - triyana@users.sourceforge.net
3 *
4 *  This source is distributed under the terms of the Q Public License version 1.0,
5 *  created by Trolltech (www.trolltech.com).
6 */
7 
8 #include "download/ClosedDay.h"
9 #include "db/DBFactory.h"
10 #include "db/Price.h"
11 #include "db/Security.h"
12 #include "Enums.h"
13 #include <MHDate.h>
14 #include <MHUtil.h>
15 #include <MHVector.h>
16 #include <stdio.h>
17 
18 
19 
20 /**
21 *
22 */
ClosedDay()23 ClosedDay::ClosedDay () :
24 BaseDownload() {
25 }
26 
27 
28 
29 /**
30 *
31 */
~ClosedDay()32 ClosedDay::~ClosedDay () {
33 }
34 
35 
36 
37 /**
38 *
39 */
Load(int type,const char * start,const char * stop,Security * sec)40 MHVector* ClosedDay::Load (int type, const char* start, const char* stop, Security* sec) {
41     MHVector* ve = 0;
42     MHVector  dates;
43     MHDate    date;
44 
45     switch (type) {
46         case XTRADER_DOWNLOAD_LATEST: {
47             ve = new MHVector();
48             ve->Push (new Price (date.Get(MHDate::LONG_DATE), Price::CLOSED, -1, -1, -1, -1, -1));
49             break;
50         }
51 
52         case XTRADER_DOWNLOAD_HISTORY: {
53             ve = new MHVector();
54             MHDate::CreateTimeSerie (start, stop, MHDate::WEEKDAY, 0, &dates);
55 
56             for (int f = 0; f < dates.Size(); f++) {
57                 MHString* s = (MHString*) dates[f];
58                 ve->Push (new Price (s->Get(), Price::CLOSED, -1, -1, -1, -1, -1));
59             }
60             dates.Erase ();
61             break;
62         }
63     }
64 
65     return ve;
66 }
67