--dl-trades should also support increasing download span
(by downloading the whole dataset again to avoid missing data in the middle).
This commit is contained in:
parent
112906458f
commit
676006b99c
@ -270,6 +270,11 @@ def _download_trades_history(exchange: Exchange,
|
|||||||
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
||||||
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
||||||
|
|
||||||
|
if trades and since < trades[0][0]:
|
||||||
|
# since is before the first trade
|
||||||
|
logger.info(f"Start earlier than available data. Redownloading trades for {pair}...")
|
||||||
|
trades = []
|
||||||
|
|
||||||
from_id = trades[-1][1] if trades else None
|
from_id = trades[-1][1] if trades else None
|
||||||
if trades and since < trades[-1][0]:
|
if trades and since < trades[-1][0]:
|
||||||
# Reset since to the last available point
|
# Reset since to the last available point
|
||||||
|
@ -1424,7 +1424,7 @@ def trades_for_order():
|
|||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def trades_history():
|
def trades_history():
|
||||||
return [[1565798399463, '126181329', None, 'buy', 0.019627, 0.04, 0.00078508],
|
return [[1565798389463, '126181329', None, 'buy', 0.019627, 0.04, 0.00078508],
|
||||||
[1565798399629, '126181330', None, 'buy', 0.019627, 0.244, 0.004788987999999999],
|
[1565798399629, '126181330', None, 'buy', 0.019627, 0.244, 0.004788987999999999],
|
||||||
[1565798399752, '126181331', None, 'sell', 0.019626, 0.011, 0.00021588599999999999],
|
[1565798399752, '126181331', None, 'sell', 0.019626, 0.011, 0.00021588599999999999],
|
||||||
[1565798399862, '126181332', None, 'sell', 0.019626, 0.011, 0.00021588599999999999],
|
[1565798399862, '126181332', None, 'sell', 0.019626, 0.011, 0.00021588599999999999],
|
||||||
|
@ -557,6 +557,7 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad
|
|||||||
assert ght_mock.call_count == 1
|
assert ght_mock.call_count == 1
|
||||||
# Check this in seconds - since we had to convert to seconds above too.
|
# Check this in seconds - since we had to convert to seconds above too.
|
||||||
assert int(ght_mock.call_args_list[0][1]['since'] // 1000) == since_time2 - 5
|
assert int(ght_mock.call_args_list[0][1]['since'] // 1000) == since_time2 - 5
|
||||||
|
assert ght_mock.call_args_list[0][1]['from_id'] is not None
|
||||||
|
|
||||||
# clean files freshly downloaded
|
# clean files freshly downloaded
|
||||||
_clean_test_file(file1)
|
_clean_test_file(file1)
|
||||||
@ -568,6 +569,27 @@ def test_download_trades_history(trades_history, mocker, default_conf, testdatad
|
|||||||
pair='ETH/BTC')
|
pair='ETH/BTC')
|
||||||
assert log_has_re('Failed to download historic trades for pair: "ETH/BTC".*', caplog)
|
assert log_has_re('Failed to download historic trades for pair: "ETH/BTC".*', caplog)
|
||||||
|
|
||||||
|
file2 = testdatadir / 'XRP_ETH-trades.json.gz'
|
||||||
|
|
||||||
|
_backup_file(file2, True)
|
||||||
|
|
||||||
|
ght_mock.reset_mock()
|
||||||
|
mocker.patch('freqtrade.exchange.Exchange.get_historic_trades',
|
||||||
|
ght_mock)
|
||||||
|
# Since before first start date
|
||||||
|
since_time = int(trades_history[0][0] // 1000) - 500
|
||||||
|
timerange = TimeRange('date', None, since_time, 0)
|
||||||
|
|
||||||
|
assert _download_trades_history(data_handler=data_handler, exchange=exchange,
|
||||||
|
pair='XRP/ETH', timerange=timerange)
|
||||||
|
|
||||||
|
assert ght_mock.call_count == 1
|
||||||
|
|
||||||
|
assert int(ght_mock.call_args_list[0][1]['since'] // 1000) == since_time
|
||||||
|
assert ght_mock.call_args_list[0][1]['from_id'] is None
|
||||||
|
assert log_has_re(r'Start earlier than available data. Redownloading trades for.*', caplog)
|
||||||
|
_clean_test_file(file2)
|
||||||
|
|
||||||
|
|
||||||
def test_convert_trades_to_ohlcv(mocker, default_conf, testdatadir, caplog):
|
def test_convert_trades_to_ohlcv(mocker, default_conf, testdatadir, caplog):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user