-
Notifications
You must be signed in to change notification settings - Fork 17
/
stock.cpp
137 lines (106 loc) · 2.72 KB
/
stock.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
#include "stock.h"
#include "qcustomplot.h"
Category::Category():
id(0),
name(""),
systemCode(""),
stocks(QStringList())
{
}
Category::Category(quint32 id, const QString &name, const QString &systemCode, const QStringList &stocks):
id(id),
name(name),
systemCode(systemCode),
stocks(stocks)
{
}
Category::~Category(){
stocks.clear();
}
TradeExtraData::TradeExtraData() :
time(0),
preClose(0),
volume(0),
turnover(0),
exchangeRatio(0)
{
}
TradeExtraData::TradeExtraData(uint key, double preClose, double volume_Hand, double turnover, double turnoverRate) :
time(key),
preClose(preClose),
volume(volume_Hand),
turnover(turnover),
exchangeRatio(turnoverRate)
{
}
RealTimeQuoteData::RealTimeQuoteData(){
code = "";
time = "";
ask1=ask2=ask3=ask4=ask5=0;
askVol1=askVol2=askVol3=askVol4=askVol5=0;
bid1=bid2=bid3=bid4=bid5=0;
bidVol1=bidVol2=bidVol3=bidVol4=bidVol5=0;
}
RealTimeStatisticsData::RealTimeStatisticsData(){
time = "";
open=high=low=price=change=changePercent=yestClose=0;
volume=turnover=exchangeRatio=0;
tradableMarketCap=marketCap=pe=earnings=0;
volChangeRatio=orderChangeRatio=0;
fiveMinsChange=0;
}
Stock::Stock(const QString &code, const QString &name, QObject *parent)
: QObject(parent),
m_code(code),
m_name(name)
{
m_realTimeStatisticsData = new RealTimeStatisticsData();
m_periodType = PERIOD_ONE_DAY;
m_ohlcData = new QMap<double, QCPFinancialData>();
m_tradeExtraData = new QMap<double, TradeExtraData>();
m_futuresDeliveryDates = new QVector<double>();
}
Stock::~Stock(){
delete m_realTimeStatisticsData;
m_realTimeStatisticsData = 0;
delete m_ohlcData; //May be deleted by QCPFinancial
m_ohlcData = 0;
delete m_tradeExtraData;
m_tradeExtraData = 0;
delete m_futuresDeliveryDates;
m_futuresDeliveryDates = 0;
}
QString Stock::code() const{
return m_code;
}
QString Stock::name() const{
return m_name;
}
void Stock::setName(const QString &name){
m_name = name;
}
RealTimeStatisticsData * Stock::realTimeStatisticsData(){
return m_realTimeStatisticsData;
}
PeriodType Stock::periodType() const{
return m_periodType;
}
QMap<double, QCPFinancialData> * Stock::ohlcDataMap(){
QMutexLocker locker(&mutex);
return m_ohlcData;
}
QMap<double, TradeExtraData> * Stock::tradeExtraDataMap(){
QMutexLocker locker(&mutex);
return m_tradeExtraData;
}
QVector<double> * Stock::futuresDeliveryDates(){
return m_futuresDeliveryDates;
}
//RealTimeData * Stock::realTimeData(){
// return m_realTimeData;
//}
void Stock::clear(){
QMutexLocker locker(&mutex);
m_ohlcData->clear();
m_tradeExtraData->clear();
}