Align tests to have futures data in futures/ directory
This commit is contained in:
parent
7baf11a497
commit
b578e31255
@ -50,6 +50,7 @@ class HDF5DataHandler(IDataHandler):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if candle_type:
|
if candle_type:
|
||||||
|
datadir = datadir.joinpath('futures')
|
||||||
candle_type = f"-{candle_type}"
|
candle_type = f"-{candle_type}"
|
||||||
else:
|
else:
|
||||||
candle_type = ""
|
candle_type = ""
|
||||||
|
@ -200,7 +200,8 @@ class IDataHandler(ABC):
|
|||||||
if candle_type:
|
if candle_type:
|
||||||
datadir = datadir.joinpath('futures')
|
datadir = datadir.joinpath('futures')
|
||||||
candle_type = f"-{candle_type}"
|
candle_type = f"-{candle_type}"
|
||||||
filename = datadir.joinpath(f'{pair_s}-{timeframe}{candle_type}.{cls._get_file_extension()}')
|
filename = datadir.joinpath(
|
||||||
|
f'{pair_s}-{timeframe}{candle_type}.{cls._get_file_extension()}')
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -50,6 +50,7 @@ class JsonDataHandler(IDataHandler):
|
|||||||
:return: List of Pairs
|
:return: List of Pairs
|
||||||
"""
|
"""
|
||||||
if candle_type:
|
if candle_type:
|
||||||
|
datadir = datadir.joinpath('futures')
|
||||||
candle_type = f"-{candle_type}"
|
candle_type = f"-{candle_type}"
|
||||||
else:
|
else:
|
||||||
candle_type = ""
|
candle_type = ""
|
||||||
|
@ -1338,10 +1338,9 @@ def test_start_list_data(testdatadir, capsys):
|
|||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_list_data(pargs)
|
start_list_data(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert "Found 20 pair / timeframe combinations." in captured.out
|
assert "Found 17 pair / timeframe combinations." in captured.out
|
||||||
assert "\n| Pair | Timeframe | Type |\n" in captured.out
|
assert "\n| Pair | Timeframe | Type |\n" in captured.out
|
||||||
assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | |\n" in captured.out
|
assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | |\n" in captured.out
|
||||||
assert "\n| UNITTEST/USDT | 1h | mark |\n" in captured.out
|
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"list-data",
|
"list-data",
|
||||||
@ -1360,6 +1359,24 @@ def test_start_list_data(testdatadir, capsys):
|
|||||||
assert "UNITTEST/BTC" not in captured.out
|
assert "UNITTEST/BTC" not in captured.out
|
||||||
assert "\n| XRP/ETH | 1m, 5m | |\n" in captured.out
|
assert "\n| XRP/ETH | 1m, 5m | |\n" in captured.out
|
||||||
|
|
||||||
|
args = [
|
||||||
|
"list-data",
|
||||||
|
"--data-format-ohlcv",
|
||||||
|
"json",
|
||||||
|
"--trading-mode", "futures",
|
||||||
|
"--datadir",
|
||||||
|
str(testdatadir),
|
||||||
|
]
|
||||||
|
pargs = get_args(args)
|
||||||
|
pargs['config'] = None
|
||||||
|
start_list_data(pargs)
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
|
||||||
|
assert "Found 3 pair / timeframe combinations." in captured.out
|
||||||
|
assert "\n| Pair | Timeframe | Type |\n" in captured.out
|
||||||
|
assert "\n| XRP/USDT | 1h | |\n" in captured.out
|
||||||
|
assert "\n| XRP/USDT | 1h | mark |\n" in captured.out
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
# TODO-lev: Short trades?
|
# TODO-lev: Short trades?
|
||||||
|
@ -98,7 +98,7 @@ def test_load_data_1min_timeframe(ohlcv_history, mocker, caplog, testdatadir) ->
|
|||||||
|
|
||||||
def test_load_data_mark(ohlcv_history, mocker, caplog, testdatadir) -> None:
|
def test_load_data_mark(ohlcv_history, mocker, caplog, testdatadir) -> None:
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=ohlcv_history)
|
mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=ohlcv_history)
|
||||||
file = testdatadir / 'UNITTEST_USDT-1h-mark.json'
|
file = testdatadir / 'futures/UNITTEST_USDT-1h-mark.json'
|
||||||
load_data(datadir=testdatadir, timeframe='1h', pairs=['UNITTEST/BTC'], candle_type='mark')
|
load_data(datadir=testdatadir, timeframe='1h', pairs=['UNITTEST/BTC'], candle_type='mark')
|
||||||
assert file.is_file()
|
assert file.is_file()
|
||||||
assert not log_has(
|
assert not log_has(
|
||||||
@ -163,8 +163,8 @@ def test_testdata_path(testdatadir) -> None:
|
|||||||
(".XBTBON2H", 'freqtrade/hello/world/_XBTBON2H-5m.json', ""),
|
(".XBTBON2H", 'freqtrade/hello/world/_XBTBON2H-5m.json', ""),
|
||||||
("ETHUSD.d", 'freqtrade/hello/world/ETHUSD_d-5m.json', ""),
|
("ETHUSD.d", 'freqtrade/hello/world/ETHUSD_d-5m.json', ""),
|
||||||
("ACC_OLD/BTC", 'freqtrade/hello/world/ACC_OLD_BTC-5m.json', ""),
|
("ACC_OLD/BTC", 'freqtrade/hello/world/ACC_OLD_BTC-5m.json', ""),
|
||||||
("ETH/BTC", 'freqtrade/hello/world/ETH_BTC-5m-mark.json', "mark"),
|
("ETH/BTC", 'freqtrade/hello/world/futures/ETH_BTC-5m-mark.json', "mark"),
|
||||||
("ACC_OLD/BTC", 'freqtrade/hello/world/ACC_OLD_BTC-5m-index.json', "index"),
|
("ACC_OLD/BTC", 'freqtrade/hello/world/futures/ACC_OLD_BTC-5m-index.json', "index"),
|
||||||
])
|
])
|
||||||
def test_json_pair_data_filename(pair, expected_result, candle_type):
|
def test_json_pair_data_filename(pair, expected_result, candle_type):
|
||||||
fn = JsonDataHandler._pair_data_filename(
|
fn = JsonDataHandler._pair_data_filename(
|
||||||
@ -254,9 +254,9 @@ def test_load_cached_data_for_updating(mocker, testdatadir) -> None:
|
|||||||
assert start_ts is None
|
assert start_ts is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('candle_type, file_tail', [
|
@pytest.mark.parametrize('candle_type,subdir,file_tail', [
|
||||||
('mark', '-mark'),
|
('mark', 'futures/', '-mark'),
|
||||||
('', ''),
|
('', '', ''),
|
||||||
])
|
])
|
||||||
def test_download_pair_history(
|
def test_download_pair_history(
|
||||||
ohlcv_history_list,
|
ohlcv_history_list,
|
||||||
@ -264,15 +264,16 @@ def test_download_pair_history(
|
|||||||
default_conf,
|
default_conf,
|
||||||
tmpdir,
|
tmpdir,
|
||||||
candle_type,
|
candle_type,
|
||||||
|
subdir,
|
||||||
file_tail
|
file_tail
|
||||||
) -> None:
|
) -> None:
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=ohlcv_history_list)
|
mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=ohlcv_history_list)
|
||||||
exchange = get_patched_exchange(mocker, default_conf)
|
exchange = get_patched_exchange(mocker, default_conf)
|
||||||
tmpdir1 = Path(tmpdir)
|
tmpdir1 = Path(tmpdir)
|
||||||
file1_1 = tmpdir1 / f'MEME_BTC-1m{file_tail}.json'
|
file1_1 = tmpdir1 / f'{subdir}MEME_BTC-1m{file_tail}.json'
|
||||||
file1_5 = tmpdir1 / f'MEME_BTC-5m{file_tail}.json'
|
file1_5 = tmpdir1 / f'{subdir}MEME_BTC-5m{file_tail}.json'
|
||||||
file2_1 = tmpdir1 / f'CFI_BTC-1m{file_tail}.json'
|
file2_1 = tmpdir1 / f'{subdir}CFI_BTC-1m{file_tail}.json'
|
||||||
file2_5 = tmpdir1 / f'CFI_BTC-5m{file_tail}.json'
|
file2_5 = tmpdir1 / f'{subdir}CFI_BTC-5m{file_tail}.json'
|
||||||
|
|
||||||
assert not file1_1.is_file()
|
assert not file1_1.is_file()
|
||||||
assert not file2_1.is_file()
|
assert not file2_1.is_file()
|
||||||
@ -707,7 +708,7 @@ def test_rebuild_pair_from_filename(input, expected):
|
|||||||
|
|
||||||
|
|
||||||
def test_datahandler_ohlcv_get_available_data(testdatadir):
|
def test_datahandler_ohlcv_get_available_data(testdatadir):
|
||||||
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir)
|
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'spot')
|
||||||
# Convert to set to avoid failures due to sorting
|
# Convert to set to avoid failures due to sorting
|
||||||
assert set(paircombs) == {
|
assert set(paircombs) == {
|
||||||
('UNITTEST/BTC', '5m', ''),
|
('UNITTEST/BTC', '5m', ''),
|
||||||
@ -727,14 +728,19 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
|
|||||||
('UNITTEST/BTC', '30m', ''),
|
('UNITTEST/BTC', '30m', ''),
|
||||||
('UNITTEST/BTC', '8m', ''),
|
('UNITTEST/BTC', '8m', ''),
|
||||||
('NOPAIR/XXX', '4m', ''),
|
('NOPAIR/XXX', '4m', ''),
|
||||||
|
}
|
||||||
|
|
||||||
|
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'futures')
|
||||||
|
# Convert to set to avoid failures due to sorting
|
||||||
|
assert set(paircombs) == {
|
||||||
('UNITTEST/USDT', '1h', 'mark'),
|
('UNITTEST/USDT', '1h', 'mark'),
|
||||||
('XRP/USDT', '1h', ''),
|
('XRP/USDT', '1h', ''),
|
||||||
('XRP/USDT', '1h', 'mark'),
|
('XRP/USDT', '1h', 'mark'),
|
||||||
}
|
}
|
||||||
|
|
||||||
paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir)
|
paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir, 'spot')
|
||||||
assert set(paircombs) == {('UNITTEST/BTC', '8m', '')}
|
assert set(paircombs) == {('UNITTEST/BTC', '8m', '')}
|
||||||
paircombs = HDF5DataHandler.ohlcv_get_available_data(testdatadir)
|
paircombs = HDF5DataHandler.ohlcv_get_available_data(testdatadir, 'spot')
|
||||||
assert set(paircombs) == {('UNITTEST/BTC', '5m', '')}
|
assert set(paircombs) == {('UNITTEST/BTC', '5m', '')}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1334,7 +1334,7 @@ def test_list_available_pairs(botclient):
|
|||||||
rc = client_get(client, f"{BASE_URI}/available_pairs")
|
rc = client_get(client, f"{BASE_URI}/available_pairs")
|
||||||
|
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
assert rc.json()['length'] == 14
|
assert rc.json()['length'] == 13
|
||||||
assert isinstance(rc.json()['pairs'], list)
|
assert isinstance(rc.json()['pairs'], list)
|
||||||
|
|
||||||
rc = client_get(client, f"{BASE_URI}/available_pairs?timeframe=5m")
|
rc = client_get(client, f"{BASE_URI}/available_pairs?timeframe=5m")
|
||||||
|
Loading…
Reference in New Issue
Block a user