Repository navigation
Expand file tree
/
Copy pathbar.cpp
More file actions
100 lines (90 loc) · 1.83 KB
/
Copy pathbar.cpp
File metadata and controls
100 lines (90 loc) · 1.83 KB
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
#include "bar.h"
Bar::Bar()
{
init();
}
Bar::Bar(const Bar &other)
{
time = other.time;
open = other.open;
high = other.high;
low = other.low;
close = other.close;
tick_volume = other.tick_volume;
volume = other.volume;
}
Bar::~Bar()
{
}
Bar::Bar(const KTExportBar &ktbar)
{
time = ktbar.m_time;
open = ktbar.m_fOpen;
high = ktbar.m_fHigh;
low = ktbar.m_fLow;
close = ktbar.m_fClose;
tick_volume = 1;
volume = ktbar.m_fVolume;
}
void Bar::init()
{
time = 0;
open = -1.5f;
high = -1.0f;
low = 100000.0f;
close = -1.0f;
tick_volume = 0;
volume = 0.0f;
}
bool Bar::isNewBar() const
{
return tick_volume == 0;
}
QDataStream& operator>>(QDataStream& s, KTExportBar& bar)
{
s >> bar.m_time;
s >> bar.m_fOpen;
s >> bar.m_fHigh;
s >> bar.m_fLow;
s >> bar.m_fClose;
s >> bar.m_fVolume;
s >> bar.m_fAmount;
s >> bar.m_wAdvance;
s >> bar.m_wDecline;
s >> bar.amount;
s >> bar.settle;
return s;
}
QDataStream& operator>>(QDataStream& s, Bar& bar)
{
s >> bar.time;
s >> bar.open;
s >> bar.high;
s >> bar.low;
s >> bar.close;
s >> bar.tick_volume;
s >> bar.volume;
return s;
}
QDataStream& operator<<(QDataStream& s, const Bar& bar)
{
s << bar.time;
s << bar.open;
s << bar.high;
s << bar.low;
s << bar.close;
s << bar.tick_volume;
s << bar.volume;
return s;
}
QDebug operator<<(QDebug dbg, const Bar &bar)
{
dbg.nospace() << "time = " << bar.time
<< ", open = " << bar.open
<< ", high = " << bar.high
<< ", low = " << bar.low
<< ", close = " << bar.close
<< ", tick_volume = " << bar.tick_volume
<< ", volume = " << bar.volume;
return dbg.space();
}