From dc87f4449bcf783eefeaa6c9a8f52a9a8307f9a6 Mon Sep 17 00:00:00 2001 From: Kuy Krawczeniuk Date: Fri, 26 Mar 2021 14:16:00 -0700 Subject: [PATCH] Add some comments to clarify the bound-setting logic. --- freqtrade/data/history/history_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index a5bbf708a..5424c24ed 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -180,18 +180,22 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *, logger.debug("Cached End: %s", 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 if cached.empty: if since: since_ms = since.timestamp() * 1000 else: + # The default lower-bound is 30 days before the current time. since_ms = arrow.utcnow().shift(days=-30).float_timestamp * \ 1000 if until: until_ms = until.timestamp() * 1000 else: + # Default upper-bound is the current time. until_ms = datetime.now(timezone.utc).timestamp() * 1000 else: + # Determine lower bound if since: if since < cached_start: since_ms = since.timestamp() * 1000 @@ -200,7 +204,10 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *, else: since_ms = cached_end.timestamp() * 1000 else: + # Set lower-bound to the end of the cache if not provided since_ms = cached_end.timestamp() * 1000 + + # Determine upper bound if until: if until < cached_start: until_ms = cached_start.timestamp() * 1000 @@ -209,6 +216,7 @@ def _download_pair_history(datadir: Path, exchange: Exchange, pair: str, *, else: until_ms = until.timestamp() else: + # Default upper-bound is the current time. until_ms = datetime.now(timezone.utc).timestamp() * 1000 new_data = exchange.get_historic_ohlcv(pair=pair,