-
Notifications
You must be signed in to change notification settings - Fork 25
/
qmydata.cpp
102 lines (82 loc) · 2.18 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
#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()
{
file->close();
}
void QMyData::GetFSJLINFO()
{
int UpRate = 0,DnRate=0;
info.Start = fsjl[0].Deal;
info.Max = fsjl[0].Deal;
for( int i=1; i<241; i++ )
{
if( info.Max < fsjl[i].Deal )
info.Max = fsjl[i].Deal;
}
info.Min = fsjl[0].Date;
for( int i=1; i<241; i++ )
{
if( info.Min > fsjl[i].Deal )
info.Min = fsjl[i].Deal;
}
if( info.Max > info.Start )
{
UpRate = (double)( info.Max - info.Start ) / info.Start * 10000;
}
if( info.Min < info.Start )
{
DnRate = (double)( info.Start - info.Min ) / info.Start * 10000;
}
if( UpRate > DnRate )
info.PerValue = ( UpRate / 40 / 5 + 1 ) * 40;
else
info.PerValue = ( DnRate / 40 / 5 + 1 ) * 40;
}
bool QMyData::ReadFSJL()
{
QString str;
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;
}