forked from dcdillon/dependable-development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
57 lines (42 loc) · 1.56 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
#include "predictor.hpp"
int main(int argc, char *argv[])
{
const std::vector< std::string > symbols {"SPY", "XLB", "XLE", "XLF", "XLI",
"XLK", "XLP", "XLU", "XLV", "XLY", "XME"};
const std::string date = "2017-01-03";
double betas[11] = {-0.3011671973112251544, -0.0015505374240656672,
0.1583297052708066144, 0.1186776199122092090, 0.2926841040343490241,
0.1496979859345836938, -0.5244559054532954567, 0.2096527161095741720,
0.0767429708349566392, 0.1425406631949422132, -0.1592688290777473648};
double prices[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Reader readers[11];
for (int i = 0; i < 11; ++i)
{
readers[i].init(symbols[i], date);
prices[i] = readers[i].price();
}
std::string time = readers[0].time();
Predictor predictor(betas, 11, .05);
while (readers[0].good())
{
std::string time = readers[0].time();
double price = readers[0].price();
for (int i = 0; i < 11; ++i)
{
while (readers[i].time() <= time)
{
readers[i].accept();
if (readers[i].peek_next() == "")
{
break;
}
}
prices[i] = readers[i].price();
}
predictor.update_prices(prices);
double prediction = predictor.predict(price);
std::cout << time << "," << prediction << std::endl;
readers[0].accept();
}
return 0;
}