diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index 74c8e8b96..27aadc17c 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -270,7 +270,8 @@ def _download_trades_history(exchange: Exchange, from_id = trades[-1][1] if trades else None if trades and since < trades[-1][0]: # Reset since to the last available point - since = trades[-1][0] + # - 5 seconds (to ensure we're getting all trades) + since = trades[-1][0] - (5 * 1000) logger.debug("Current Start: %s", trades[0][0] if trades else 'None') logger.debug("Current End: %s", trades[-1][0] if trades else 'None') diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 12390538a..fedf63353 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -548,6 +548,17 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad assert file1.is_file() # clean files freshly downloaded + _clean_test_file(file1) + ght_mock.reset_mock() + since_time = int(trades_history[-2][0] // 1000) + timerange = TimeRange('date', None, since_time, 0) + assert _download_trades_history(data_handler=data_handler, exchange=exchange, + pair='ETH/BTC', timerange=timerange) + + assert ght_mock.call_count == 1 + # Check this in seconds - since we had to convert to seconds above too. + assert int(ght_mock.call_args_list[0].kwargs['since'] // 1000) == since_time - 5 + _clean_test_file(file1) mocker.patch('freqtrade.exchange.Exchange.get_historic_trades',