-
Notifications
You must be signed in to change notification settings - Fork 16
/
qmydata.cpp
103 lines (81 loc) · 2.35 KB
/
qmydata.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
#include "qmydata.h"
QMyData::QMyData()
{
memset(fsjl,0,sizeof(FSJL)*241);
}
QMyData::QMyData( char* SecID, char* Date )
{
strcpy(szSecID , SecID );
strcpy( szDate , Date) ;
memset(fsjl,0,sizeof(FSJL)*241);
}
QMyData::~QMyData()
{
if( nullptr != file )
file->close();
}
void QMyData::GetFSJLINFO()
{
double UpRate = 0, DnRate = 0;
info.deal_Start = info.deal_Max = info.deal_Min = fsjl[0].Deal;
info.vol_Max = info.vol_Min = 0;
for( int i=1; i<241; i++ )
{
if( info.deal_Max < fsjl[i].Deal )
info.deal_Max = fsjl[i].Deal;
if( info.deal_Min > fsjl[i].Deal )
info.deal_Min = fsjl[i].Deal;
if(info.vol_Max < fsjl[i].Vol)
info.vol_Max = fsjl[i].Vol;
if(info.vol_Min > fsjl[i].Vol)
info.vol_Min = fsjl[i].Vol;
}
qDebug("%d",info.deal_Max);
if( info.deal_Max > info.deal_Start)
{
UpRate = ( info.deal_Max - info.deal_Start ) / info.deal_Start ;
}
if( info.deal_Min < info.deal_Start)
{
DnRate = ( info.deal_Start - info.deal_Min ) / info.deal_Start ;
}
info.deal_rate = UpRate > DnRate ? UpRate : DnRate ;
}
bool QMyData::ReadFSJL()
{
QString str("FSJL.000001K.20100310");
char line[1024];
char *token;
//str.sprintf(+"FSJL.%s.%s",szSecID,szDate);
file = new QFile(str);
if( !file->open(QFile::ReadOnly) )
return false;
for( int i=0; i < 241; i++ )
{
if( file->readLine(line,1024) > 0 )
{
token = strtok( line, "|" );
if( token != NULL )
fsjl[i].Date = atoi(token);
token = strtok( NULL, "|" );
if( token != NULL )
fsjl[i].Time = atoi(token);
token = strtok( NULL, "|" );
if( token != NULL )
strcpy(fsjl[i].SecID,token);
token = strtok( NULL, "|" );
if( token != NULL )
strcpy(fsjl[i].SecName,token);
token = strtok( NULL, "|" );
if( token != NULL )
fsjl[i].Deal = atoi(token);
token = strtok( NULL, "|" );
if( token != NULL )
fsjl[i].Vol = atoi(token);
token = strtok( NULL, "|" );
if( token != NULL )
fsjl[i].Amt = atoi(token);
}
}
return true;
}