-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
160 lines (154 loc) · 5.17 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Pro_Script1.cpp : Defines the entry point for the console application.
// Lucas's PC 4/25/2018
/*
Update log:
5/9/2018 Fix MulGetData tm_mon+1
5/2/2018 Resampling applied to fix AR issue. Menu and informing notices implemented. FinalVersion1.0
5/1/2018 Multi-thread download applied. Bug: Might stuck or abort sometimes.
4/28/2018 Excel driver issue fixed. Current issue: libcurl extremely slow. AR might be inf for some samples.
4/27/2018 All parts combined. Excel driver cannot be initialized.
*/
#include <iostream>
#include "Boost.h"
#include "Getdata.hpp"
#include "MulGetData.h"
using namespace std;
int main() {
int choice;
cout << endl;
cout << "--------------------------------------------------------------------------" << endl
<< "| ______ __ ____ _ __ ___ ____ _ |" << endl
<< "| || //\\\\ || \\\\ || || \\\\ || || || \\\\ || |" << endl
<< "| || //==\\\\ || \\\\ || || || || || || \\\\ || |" << endl
<< "| || // \\\\ || \\\\|| ||__// ||___|| || \\\\|| |" << endl
<< "| |" << endl
<< "|Financial Computing Final Project |" << endl
<< "|Author:Florence, Kyle, Li, Lucas, Yicheng |" << endl
<< "|Please enter numbers 1 - 5 to choose different options |" << endl
<< "--------------------------------------------------------------------------" << endl
<< "1: Retrieve historical price data for all stocks." << endl
<< "2: Pull information for one stock from one group" << endl
<< "3: Show AAR or CAAR for one group" << endl
<< "4: Show the Excel graph with CAAR for all 3 groups" << endl
<< "5: Exit your program" << endl;
map<string, Stock> All_Stocks;
Share SPY;
Boost Boo;
double threshold;
while (1) {
cout << "Before initializing the program, please enter the threshold for bootstrapping between 5 to 10:";
cin >> threshold;
if (threshold < 5 || threshold >10)
cout << "Don't you dare messing up with me";
else
break;
}
Boo.SetThreshold(threshold);
cout << "Program initializing completed." << endl;
while (1) {
while (1) {
cout << "Tell me what you want, do not do anything before retrieving data" << endl;
cin >> choice;
if (cin.fail() || choice <1 || choice >5) // in case input is not integer
{
cout << "HEY!!!!YOU ONLY HAVE 5 OPTIONS!!! Don't mess it up with me" << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
continue;
}
else {
break;
}
}
switch (choice) {
case 1: {
//This is loop download
/*string sCrumb;
string sCookies;
AllStock(All_Stocks);
GetspyAlsoGetCrumb(SPY, sCrumb, sCookies);
pricehandle(All_Stocks, sCrumb, sCookies);*/
//
////This is multithread
MulAllStock(All_Stocks);
MulTimeForMagic(All_Stocks, SPY);
break;
}
case 2: {
if (All_Stocks.size() == 0) {
cout << "I told you do not do anything before retrieving data. Don't mess it up with me" << endl;
break;
}
string temp;
cout << "Tell me what you want" << endl;
cin >> temp;
auto whatyouwant = All_Stocks.find(temp);
if (whatyouwant != All_Stocks.end())
whatyouwant->second.Display(threshold);
else
cout <<"Seriously? I cannot find it. Bye" << endl;
break;
}
case 3: {
if (All_Stocks.size() == 0) {
cout << "I told you do not do anything before retrieving data. Don't mess it up with me" << endl;
break;
}
int temp;
cout << "Which group do you want?" << endl;
cin >> temp;
string ar;
cout << "AAR or CAAR?" << endl;
cin >> ar;
Boo.WriteGroups(All_Stocks);
Boo.Bootstrap(SPY);
if (ar == "AAR") {
for (int i = 1; i <= 90; i++)
cout << Boo.GetAAR_CAAR(long(temp), long(1))[i] << endl;
}
else if (ar == "CAAR") {
for (int i = 1; i <=90; i++)
cout << Boo.GetAAR_CAAR(long(temp), long(2))[i] << endl;
}
else {
cout << "Huh???? Say that again??" << endl;
}
break;
}
case 4: {
if (All_Stocks.size() == 0) {
cout << "I told you do not do anything before retrieving data. Don't mess it up with me" << endl;
break;
}
if (Boo.GetGroup(1).Gettickers().size() == 0) {
Boo.WriteGroups(All_Stocks);
Boo.Bootstrap(SPY);
}// if we didn't run case 3 first, we need run this part
list<string> group;
group.push_back("Beat");
group.push_back("Meet");
group.push_back("Miss");
Vector<double, long> x(Boo.GetCAARlist().front().MaxIndex());//.begin()
//cout << Boo.GetCAARlist().front().MaxIndex() << endl;
for (long i = x.MinIndex(); i <= x.MaxIndex(); i++) {
x[i] = i - 60;
}//x is x-axis
ExcelDriver& excel = ExcelDriver::Instance();
excel.MakeVisible(true);//show up
printInExcel(x, group, Boo.GetCAARlist(), string("CAAR"), string("Days to Report day"), string("CAAR"));
break;
}
case 5: {
cout << "Self-destruct initialized. Exploding counting down in process." << endl
<< "5" << endl
<< "4" << endl
<< "3" << endl
<< "2" << endl
<< "1" << endl
<< "I am kidding. Bye" << endl;
system("pause");
return 0;
}
}
}
}