From 88da1f109b3563a0f3c59d643be9c67de8ed0b89 Mon Sep 17 00:00:00 2001 From: Brook Miles Date: Sat, 15 May 2021 20:15:19 +0900 Subject: [PATCH 1/2] fix #4412 download-data does not stop downloading at the specified TIMERANGE end date --- freqtrade/data/history/history_utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index 32c7ce7f9..383913f66 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -265,9 +265,13 @@ def _download_trades_history(exchange: Exchange, """ try: - since = timerange.startts * 1000 if \ - (timerange and timerange.starttype == 'date') else int(arrow.utcnow().shift( - days=-new_pairs_days).float_timestamp) * 1000 + until = None + if (timerange and timerange.starttype == 'date'): + since = timerange.startts * 1000 + if timerange.stoptype == 'date': + until = timerange.stopts * 1000 + else: + since = int(arrow.utcnow().shift(days=-new_pairs_days).float_timestamp) * 1000 trades = data_handler.trades_load(pair) @@ -295,6 +299,7 @@ def _download_trades_history(exchange: Exchange, # Default since_ms to 30 days if nothing is given new_trades = exchange.get_historic_trades(pair=pair, since=since, + until=until, from_id=from_id, ) trades.extend(new_trades[1]) From db17b1a851f749afc0335a8579e0dc1df19c47ce Mon Sep 17 00:00:00 2001 From: Brook Miles Date: Sat, 15 May 2021 20:20:36 +0900 Subject: [PATCH 2/2] fix indentation --- freqtrade/data/history/history_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index 383913f66..86e9f75e6 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -267,11 +267,11 @@ def _download_trades_history(exchange: Exchange, until = None if (timerange and timerange.starttype == 'date'): - since = timerange.startts * 1000 - if timerange.stoptype == 'date': - until = timerange.stopts * 1000 + since = timerange.startts * 1000 + if timerange.stoptype == 'date': + until = timerange.stopts * 1000 else: - since = int(arrow.utcnow().shift(days=-new_pairs_days).float_timestamp) * 1000 + since = int(arrow.utcnow().shift(days=-new_pairs_days).float_timestamp) * 1000 trades = data_handler.trades_load(pair)