Add test for binance data migration
This commit is contained in:
parent
cbcee02ded
commit
5d4a247fa0
@ -55,7 +55,7 @@ def migrate_binance_futures_data(config: Config):
|
|||||||
return
|
return
|
||||||
|
|
||||||
from freqtrade.data.history.idatahandler import get_datahandler
|
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(
|
paircombs = dhc.ohlcv_get_available_data(
|
||||||
config['datadir'],
|
config['datadir'],
|
||||||
|
37
tests/test_binance_mig.py
Normal file
37
tests/test_binance_mig.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user