final ohlc bugfix
This commit is contained in:
@@ -187,9 +187,10 @@ class OHLCFile:
|
||||
offset = self.file.tell() # this will end up pointing to the start of the last row
|
||||
for line in self.file.readlines(): # all files should be small and can load at once
|
||||
line_number += 1
|
||||
row = line.decode('ascii').strip().split(',')
|
||||
if not row[0]: # empty line
|
||||
split = line.decode('ascii').strip().split(',')
|
||||
if not split[0]: # empty line. do not replace row.
|
||||
continue
|
||||
row = split
|
||||
if prev_line is not None:
|
||||
# advance cursor past the previous row
|
||||
offset += len(prev_line)
|
||||
@@ -202,7 +203,7 @@ class OHLCFile:
|
||||
log.error(f'Couldn\'t read line {line_number} in {self.filename} row {row}')
|
||||
raise
|
||||
prev_line = line
|
||||
if row is not None:
|
||||
if row is not None and row[0]:
|
||||
try:
|
||||
self._cur = [int(row[0]), *(dec(p) for p in row[1:])] # convert to int timestamp and dec prices
|
||||
except:
|
||||
@@ -313,7 +314,7 @@ class OHLCFileSeries:
|
||||
#
|
||||
try:
|
||||
start_of_column = self.quote_file.tell()
|
||||
self.quote_file.write(f'{ts},{price:f}'.encode('ascii'))
|
||||
self.quote_file.write(f'{ts},{price:f}\n'.encode('ascii'))
|
||||
self.quote_file.truncate()
|
||||
self.quote_file.flush()
|
||||
self.quote_file.seek(start_of_column)
|
||||
|
||||
Reference in New Issue
Block a user