@@ -29,7 +29,7 @@ def _checkFormat(self):
29
29
if (len (self .content ) - self .headerLength )% self .rowLength != 0 :
30
30
print ('[ERROR] File length isn\' t valid for this kind of format!' )
31
31
32
- if self .version != unpack ('<i' , self .content [0 :4 ])[0 ]:
32
+ if self .version != struct . unpack ('<i' , self .content [0 :4 ])[0 ]:
33
33
print ('[ERROR] Unsupported format version!' )
34
34
sys .exit (1 )
35
35
@@ -127,12 +127,12 @@ def _parse(self):
127
127
for i in range (0 , self .numberOfRows ):
128
128
base = self .headerLength + i * self .rowLength
129
129
self .rows += [{'timestamp' : datetime .datetime .fromtimestamp (
130
- unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
131
- 'open' : unpack ('<d' , self .content [base + 4 :base + 4 + 8 ])[0 ],
132
- 'low' : unpack ('<d' , self .content [base + 4 + 8 :base + 4 + 2 * 8 ])[0 ],
133
- 'high' : unpack ('<d' , self .content [base + 4 + 2 * 8 :base + 4 + 3 * 8 ])[0 ],
134
- 'close' : unpack ('<d' , self .content [base + 4 + 3 * 8 :base + 4 + 4 * 8 ])[0 ],
135
- 'volume' : unpack ('<d' , self .content [base + 4 + 4 * 8 :base + 4 + 5 * 8 ])[0 ]
130
+ struct . unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
131
+ 'open' : struct . unpack ('<d' , self .content [base + 4 :base + 4 + 8 ])[0 ],
132
+ 'low' : struct . unpack ('<d' , self .content [base + 4 + 8 :base + 4 + 2 * 8 ])[0 ],
133
+ 'high' : struct . unpack ('<d' , self .content [base + 4 + 2 * 8 :base + 4 + 3 * 8 ])[0 ],
134
+ 'close' : struct . unpack ('<d' , self .content [base + 4 + 3 * 8 :base + 4 + 4 * 8 ])[0 ],
135
+ 'volume' : struct . unpack ('<d' , self .content [base + 4 + 4 * 8 :base + 4 + 5 * 8 ])[0 ]
136
136
}]
137
137
138
138
@@ -178,14 +178,14 @@ def _parse(self):
178
178
for i in range (0 , self .numberOfRows ):
179
179
base = self .headerLength + i * self .rowLength
180
180
self .rows += [{'timestamp' : datetime .datetime .fromtimestamp (
181
- unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
182
- 'open' : unpack ('<d' , self .content [base + 8 :base + 2 * 8 ])[0 ],
183
- 'high' : unpack ('<d' , self .content [base + 2 * 8 :base + 3 * 8 ])[0 ],
184
- 'low' : unpack ('<d' , self .content [base + 3 * 8 :base + 4 * 8 ])[0 ],
185
- 'close' : unpack ('<d' , self .content [base + 4 * 8 :base + 5 * 8 ])[0 ],
186
- 'volume' : unpack ('<Q' , self .content [base + 5 * 8 :base + 6 * 8 ])[0 ],
187
- 'spread' : unpack ('<i' , self .content [base + 6 * 8 :base + 4 + 6 * 8 ])[0 ],
188
- 'realVolume' : unpack ('<Q' , self .content [base + 4 + 6 * 8 :base + 4 + 7 * 8 ])[0 ]
181
+ struct . unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
182
+ 'open' : struct . unpack ('<d' , self .content [base + 8 :base + 2 * 8 ])[0 ],
183
+ 'high' : struct . unpack ('<d' , self .content [base + 2 * 8 :base + 3 * 8 ])[0 ],
184
+ 'low' : struct . unpack ('<d' , self .content [base + 3 * 8 :base + 4 * 8 ])[0 ],
185
+ 'close' : struct . unpack ('<d' , self .content [base + 4 * 8 :base + 5 * 8 ])[0 ],
186
+ 'volume' : struct . unpack ('<Q' , self .content [base + 5 * 8 :base + 6 * 8 ])[0 ],
187
+ 'spread' : struct . unpack ('<i' , self .content [base + 6 * 8 :base + 4 + 6 * 8 ])[0 ],
188
+ 'realVolume' : struct . unpack ('<Q' , self .content [base + 4 + 6 * 8 :base + 4 + 7 * 8 ])[0 ]
189
189
}]
190
190
191
191
@@ -237,15 +237,15 @@ def _parse(self):
237
237
for i in range (0 , self .numberOfRows ):
238
238
base = self .headerLength + i * self .rowLength
239
239
self .rows += [{'barTimestamp' : datetime .datetime .fromtimestamp (
240
- unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
241
- 'open' : unpack ('<d' , self .content [base + 8 :base + 2 * 8 ])[0 ],
242
- 'high' : unpack ('<d' , self .content [base + 2 * 8 :base + 3 * 8 ])[0 ],
243
- 'low' : unpack ('<d' , self .content [base + 3 * 8 :base + 4 * 8 ])[0 ],
244
- 'close' : unpack ('<d' , self .content [base + 4 * 8 :base + 5 * 8 ])[0 ],
245
- 'volume' : unpack ('<Q' , self .content [base + 5 * 8 :base + 6 * 8 ])[0 ],
240
+ struct . unpack ('<i' , self .content [base :base + 4 ])[0 ], datetime .timezone .utc ),
241
+ 'open' : struct . unpack ('<d' , self .content [base + 8 :base + 2 * 8 ])[0 ],
242
+ 'high' : struct . unpack ('<d' , self .content [base + 2 * 8 :base + 3 * 8 ])[0 ],
243
+ 'low' : struct . unpack ('<d' , self .content [base + 3 * 8 :base + 4 * 8 ])[0 ],
244
+ 'close' : struct . unpack ('<d' , self .content [base + 4 * 8 :base + 5 * 8 ])[0 ],
245
+ 'volume' : struct . unpack ('<Q' , self .content [base + 5 * 8 :base + 6 * 8 ])[0 ],
246
246
'tickTimestamp' : datetime .datetime .fromtimestamp (
247
- unpack ('<i' , self .content [base + 6 * 8 :base + 4 + 6 * 8 ])[0 ], datetime .timezone .utc ),
248
- 'flag' : unpack ('<i' , self .content [base + 4 + 6 * 8 :base + 7 * 8 ])[0 ]
247
+ struct . unpack ('<i' , self .content [base + 6 * 8 :base + 4 + 6 * 8 ])[0 ], datetime .timezone .utc ),
248
+ 'flag' : struct . unpack ('<i' , self .content [base + 4 + 6 * 8 :base + 7 * 8 ])[0 ]
249
249
}]
250
250
251
251
0 commit comments