-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gluon.cpp
86 lines (67 loc) · 1.88 KB
/
Gluon.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
#include "Ensembleizer.h"
#include "Gluon.h"
Gluon::Gluon()
: m_ptr_ensemble(new Ensembleizer(this))
{
m_boson_map.clear();
}
Gluon::~Gluon()
{
}
void Gluon::loadConfigParams()
{
m_ptr_ensemble->loadConfigs();
}
Boson* Gluon::getBoson( BosonId id )
{
m_bmit = m_boson_map.find(id);
if ( m_bmit == m_boson_map.end() ) {
std::cerr << "WARNING: Gluon.cpp: Could not find id ("
<< id << ") in map." << std::endl;
return NULL;
}
Boson* b = m_bmit->second;
return b;
}
bool Gluon::addNewBosonToMap( Boson* b )
{
BosonId id = b->getBosonId();
m_bmit = m_boson_map.find(id);
if ( m_bmit != m_boson_map.end() ) {
Boson* tmp = m_bmit->second;
std::cerr << "WARNING: Gluon.cpp: Boson ("
<< tmp->getBosonId() << ") already in map." << std::endl;
return false;
}
m_boson_map[id] = b;
return true;
}
bool Gluon::recordNewTick( BosonId ticker_id, PropertyType p, TypeOfTick t, int size )
{
if ( p != e_size_property ) {
std::cerr << "ERROR: Gluon.cpp: Incorrect call of recordNewTick. p ("
<< p << ")" << std::endl;
return false;
}
Boson* b = getBoson(ticker_id);
b->recordSize(t, size);
updateDependencies(b,t);
}
bool Gluon::recordNewTick( BosonId ticker_id, PropertyType p, TypeOfTick t, double price )
{
if ( p != e_price_property ) {
std::cerr << "ERROR: Gluon.cpp: Incorrect call of recordNewTick. p ("
<< p << ")" << std::endl;
return false;
}
Boson* b = getBoson(ticker_id);
b->recordPrice(t, price);
updateDependencies(b,t);
}
void Gluon::updateDependencies( Boson* b, TypeOfTick t )
{
// external call to the main computation loop.
// for each algo (algo's have to register themselves),
// call the algo's updateState()
b->updateMacroStates(t);
}