quote.csv file bugfix; adjusted ohlc file grouping
This commit is contained in:
@@ -3,3 +3,4 @@ ws_url = ''
|
||||
redis_url = ''
|
||||
ohlc_dir = '/ohlc'
|
||||
walker_flush_interval=25
|
||||
concurrent_rpc_connections=9999
|
||||
|
||||
@@ -24,14 +24,14 @@ class OHLCFilePath:
|
||||
self.period = period
|
||||
name = period_name(period)
|
||||
self.filepath = f'{symbol}/{name}/'
|
||||
if period < timedelta(minutes=15):
|
||||
if period < timedelta(hours=1):
|
||||
# one file per day is the smallest resolution
|
||||
# log.debug(f'{name} is daily')
|
||||
self.start = start = datetime(time.year, time.month, time.day, tzinfo=timezone.utc)
|
||||
self.end = self.start + timedelta(days=1)
|
||||
self.file_interval = timedelta(days=1)
|
||||
self.filepath += f'{start.year}/{start.month}/{symbol}-{name}-{start:%Y%m%d}.csv'
|
||||
elif period < timedelta(hours=8):
|
||||
elif period < timedelta(days=1):
|
||||
# one file per month
|
||||
# log.debug(f'{name} is monthly')
|
||||
self.start = start = datetime(time.year, time.month, 1, tzinfo=timezone.utc)
|
||||
@@ -324,10 +324,10 @@ class OHLCFileSeries:
|
||||
# flush quote file
|
||||
#
|
||||
try:
|
||||
start_of_column = self.quote_file.tell()
|
||||
if self.start_time_bytes:
|
||||
self.quote_file.write(self.start_time_bytes)
|
||||
self.start_time_bytes = None
|
||||
start_of_column = self.quote_file.tell()
|
||||
self.quote_file.write(f'{ts},{price:f}\n'.encode('ascii'))
|
||||
self.quote_file.truncate()
|
||||
self.quote_file.flush()
|
||||
|
||||
@@ -34,7 +34,8 @@ OHLC_PERIODS = [
|
||||
timedelta(days=1), timedelta(days=2), timedelta(days=3), timedelta(days=7)
|
||||
]
|
||||
|
||||
OHLC_DATE_ROOT = datetime(2009, 1, 4, tzinfo=timezone.utc) # Sunday before Bitcoin Genesis
|
||||
# Sunday before Bitcoin Genesis. Timestamp: 1231027200
|
||||
OHLC_DATE_ROOT = datetime(2009, 1, 4, tzinfo=timezone.utc)
|
||||
|
||||
# OHLC's are stored as [timestamp, open, high, low, close] with prices as string values. If there was no data during
|
||||
# the interval, then open, high, and low are None but the close value is carried over from the previous interval.
|
||||
|
||||
Reference in New Issue
Block a user