Add some comments to clarify the bound-setting logic.
This commit is contained in:
parent
f21ef11db0
commit
dc87f4449b
@ -180,18 +180,22 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *,
|
|||||||
logger.debug("Cached End: %s",
|
logger.debug("Cached End: %s",
|
||||||
f"{cached_end:%Y-%m-%d %H:%M:%S}" if not cached_end else 'None')
|
f"{cached_end:%Y-%m-%d %H:%M:%S}" if not cached_end else 'None')
|
||||||
|
|
||||||
|
# Set the bounds for downloading
|
||||||
since_ms, until_ms = None, None
|
since_ms, until_ms = None, None
|
||||||
if cached.empty:
|
if cached.empty:
|
||||||
if since:
|
if since:
|
||||||
since_ms = since.timestamp() * 1000
|
since_ms = since.timestamp() * 1000
|
||||||
else:
|
else:
|
||||||
|
# The default lower-bound is 30 days before the current time.
|
||||||
since_ms = arrow.utcnow().shift(days=-30).float_timestamp * \
|
since_ms = arrow.utcnow().shift(days=-30).float_timestamp * \
|
||||||
1000
|
1000
|
||||||
if until:
|
if until:
|
||||||
until_ms = until.timestamp() * 1000
|
until_ms = until.timestamp() * 1000
|
||||||
else:
|
else:
|
||||||
|
# Default upper-bound is the current time.
|
||||||
until_ms = datetime.now(timezone.utc).timestamp() * 1000
|
until_ms = datetime.now(timezone.utc).timestamp() * 1000
|
||||||
else:
|
else:
|
||||||
|
# Determine lower bound
|
||||||
if since:
|
if since:
|
||||||
if since < cached_start:
|
if since < cached_start:
|
||||||
since_ms = since.timestamp() * 1000
|
since_ms = since.timestamp() * 1000
|
||||||
@ -200,7 +204,10 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *,
|
|||||||
else:
|
else:
|
||||||
since_ms = cached_end.timestamp() * 1000
|
since_ms = cached_end.timestamp() * 1000
|
||||||
else:
|
else:
|
||||||
|
# Set lower-bound to the end of the cache if not provided
|
||||||
since_ms = cached_end.timestamp() * 1000
|
since_ms = cached_end.timestamp() * 1000
|
||||||
|
|
||||||
|
# Determine upper bound
|
||||||
if until:
|
if until:
|
||||||
if until < cached_start:
|
if until < cached_start:
|
||||||
until_ms = cached_start.timestamp() * 1000
|
until_ms = cached_start.timestamp() * 1000
|
||||||
@ -209,6 +216,7 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *,
|
|||||||
else:
|
else:
|
||||||
until_ms = until.timestamp()
|
until_ms = until.timestamp()
|
||||||
else:
|
else:
|
||||||
|
# Default upper-bound is the current time.
|
||||||
until_ms = datetime.now(timezone.utc).timestamp() * 1000
|
until_ms = datetime.now(timezone.utc).timestamp() * 1000
|
||||||
|
|
||||||
new_data = exchange.get_historic_ohlcv(pair=pair,
|
new_data = exchange.get_historic_ohlcv(pair=pair,
|
||||||
|
Loading…
Reference in New Issue
Block a user