OHLC debug facility
This commit is contained in:
@@ -16,6 +16,9 @@ from dexorder.util.shutdown import fatal
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
OHLC_LIMIT_POOLS_DEBUG = None
|
||||
# OHLC_LIMIT_POOLS_DEBUG = [('0xE4DC98552A7c79Cc8d79DE7D4285BBab613cd31e',timedelta(minutes=1))]
|
||||
|
||||
OHLC_PERIODS = [
|
||||
timedelta(minutes=1),
|
||||
timedelta(minutes=3), timedelta(minutes=5), timedelta(minutes=10), timedelta(minutes=15), timedelta(minutes=30),
|
||||
@@ -339,6 +342,8 @@ class OHLCRepository:
|
||||
"""
|
||||
if price is None, then bars are advanced based on the time but no new price is added to the series.
|
||||
"""
|
||||
if OHLC_LIMIT_POOLS_DEBUG is not None and (symbol,period) not in OHLC_LIMIT_POOLS_DEBUG:
|
||||
return
|
||||
# logname = f'{symbol} {period_name(period)}'
|
||||
# log.debug(f'Updating OHLC {logname} {minutely(time)} {price}')
|
||||
if price is not None:
|
||||
@@ -347,13 +352,13 @@ class OHLCRepository:
|
||||
# recent_ohlcs holds a list of "recent" NativeOHLC's stored as blockdata. we try to keep the recent array long
|
||||
# enough to extend prior the root block time
|
||||
historical: Optional[list[NativeOHLC]] = recent_ohlcs.get(key)
|
||||
# log.debug(f'got recent {historical}')
|
||||
log.debug(f'got recent {historical}')
|
||||
if not historical:
|
||||
if create is False or price is None:
|
||||
return # do not track symbols which have not been explicity set up
|
||||
historical = []
|
||||
updated = [NativeOHLC(ohlc_start_time(time, period), price, price, price, price)]
|
||||
# log.debug(f'\tcreated new bars {updated}')
|
||||
log.debug(f'\tcreated new bars {updated}')
|
||||
else:
|
||||
updated = update_ohlc(historical[-1], period, time, price)
|
||||
# drop any historical bars that are older than we need
|
||||
@@ -372,7 +377,7 @@ class OHLCRepository:
|
||||
first_updated = updated[0].start
|
||||
overlap = (first_updated - last_bar) // period + 1
|
||||
updated = historical[:-overlap] + updated if overlap > 0 else historical + updated
|
||||
# log.debug(f'\tnew recents: {updated}')
|
||||
log.debug(f'\tnew recents: {updated}')
|
||||
recent_ohlcs.setitem(key, updated)
|
||||
return updated
|
||||
|
||||
@@ -441,6 +446,8 @@ class FinalOHLCRepository (OHLCRepository):
|
||||
|
||||
def light_update(self, symbol: str, period: timedelta, time: datetime, price: Optional[dec] = None,
|
||||
*, backfill=True):
|
||||
if OHLC_LIMIT_POOLS_DEBUG is not None and (symbol,period) not in OHLC_LIMIT_POOLS_DEBUG:
|
||||
return
|
||||
if price is not None:
|
||||
self.quotes[symbol] = timestamp(time), str(price)
|
||||
start = ohlc_start_time(time, period)
|
||||
|
||||
Reference in New Issue
Block a user