diff --git a/freqtrade/util/binance_mig.py b/freqtrade/util/binance_mig.py index 06cd85d1d..366eaa2b7 100644 --- a/freqtrade/util/binance_mig.py +++ b/freqtrade/util/binance_mig.py @@ -55,7 +55,7 @@ def migrate_binance_futures_data(config: Config): return from freqtrade.data.history.idatahandler import get_datahandler - dhc = get_datahandler(config['datadir'], config['dataformat_ohlcv']) + dhc = get_datahandler(config['datadir'], config.get('dataformat_ohlcv', 'json')) paircombs = dhc.ohlcv_get_available_data( config['datadir'], diff --git a/tests/test_binance_mig.py b/tests/test_binance_mig.py new file mode 100644 index 000000000..4bc917265 --- /dev/null +++ b/tests/test_binance_mig.py @@ -0,0 +1,37 @@ + + +import shutil +from pathlib import Path + +from freqtrade.util.binance_mig import migrate_binance_futures_data + + +def test_binance_mig_data_conversion(default_conf_usdt, tmpdir, testdatadir): + + # call doing nothing (spot mode) + migrate_binance_futures_data(default_conf_usdt) + default_conf_usdt['trading_mode'] = 'futures' + pair_old = 'XRP_USDT' + pair_unified = 'XRP_USDT_USDT' + futures_src = testdatadir / 'futures' + futures_dst = tmpdir / 'futures' + futures_dst.mkdir() + files = [ + '-1h-mark.json', + '-1h-futures.json', + '-8h-funding_rate.json', + '-8h-mark.json', + ] + + # Copy files to tmpdir and rename to old naming + for file in files: + fn_after = futures_dst / f'{pair_old}{file}' + shutil.copy(futures_src / f'{pair_unified}{file}', fn_after) + + default_conf_usdt['datadir'] = Path(tmpdir) + # Migrate files to unified namings + migrate_binance_futures_data(default_conf_usdt) + + for file in files: + fn_after = futures_dst / f'{pair_unified}{file}' + assert fn_after.exists()