Update converter tests

This commit is contained in:
Matthias 2021-12-07 06:54:00 +01:00
parent a58c2c4f6c
commit 5a3b907132
5 changed files with 31 additions and 27 deletions

View File

@ -1374,7 +1374,7 @@ def test_start_list_data(testdatadir, capsys):
assert "Found 3 pair / timeframe combinations." in captured.out assert "Found 3 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| XRP/USDT | 1h | |\n" in captured.out assert "\n| XRP/USDT | 1h | futures |\n" in captured.out
assert "\n| XRP/USDT | 1h | mark |\n" in captured.out assert "\n| XRP/USDT | 1h | mark |\n" in captured.out

View File

@ -12,6 +12,7 @@ from freqtrade.data.converter import (convert_ohlcv_format, convert_trades_forma
trades_to_ohlcv, trim_dataframe) trades_to_ohlcv, trim_dataframe)
from freqtrade.data.history import (get_timerange, load_data, load_pair_history, from freqtrade.data.history import (get_timerange, load_data, load_pair_history,
validate_backtest_data) validate_backtest_data)
from freqtrade.data.history.idatahandler import IDataHandler
from freqtrade.enums import CandleType from freqtrade.enums import CandleType
from tests.conftest import log_has, log_has_re from tests.conftest import log_has, log_has_re
from tests.data.test_history import _clean_test_file from tests.data.test_history import _clean_test_file
@ -135,7 +136,8 @@ def test_ohlcv_fill_up_missing_data2(caplog):
def test_ohlcv_drop_incomplete(caplog): def test_ohlcv_drop_incomplete(caplog):
timeframe = '1d' timeframe = '1d'
ticks = [[ ticks = [
[
1559750400000, # 2019-06-04 1559750400000, # 2019-06-04
8.794e-05, # open 8.794e-05, # open
8.948e-05, # high 8.948e-05, # high
@ -289,17 +291,19 @@ def test_convert_trades_format(default_conf, testdatadir, tmpdir):
file['new'].unlink() file['new'].unlink()
@pytest.mark.parametrize('file_base', [ @pytest.mark.parametrize('file_base,candletype', [
('XRP_ETH-5m'), ('XRP_ETH-5m', CandleType.SPOT),
('XRP_ETH-1m'), ('XRP_ETH-1m', CandleType.SPOT),
# ('XRP_USDT-1h-mark'), #TODO-lev: Create .gz file ('XRP_USDT-1h-mark', CandleType.MARK),
('XRP_USDT-1h-futures', CandleType.FUTURES),
]) ])
def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base): def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base, candletype):
tmpdir1 = Path(tmpdir) tmpdir1 = Path(tmpdir)
prependix = '' if candletype == CandleType.SPOT else 'futures/'
file_orig = testdatadir / f"{file_base}.json" file_orig = testdatadir / f"{prependix}{file_base}.json"
file_temp = tmpdir1 / f"{file_base}.json" file_temp = tmpdir1 / f"{prependix}{file_base}.json"
file_new = tmpdir1 / f"{file_base}.json.gz" file_new = tmpdir1 / f"{prependix}{file_base}.json.gz"
IDataHandler.create_dir_if_needed(file_temp)
copyfile(file_orig, file_temp) copyfile(file_orig, file_temp)
@ -314,7 +318,7 @@ def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base):
convert_from='json', convert_from='json',
convert_to='jsongz', convert_to='jsongz',
erase=False, erase=False,
candle_type=CandleType.SPOT candle_type=candletype
) )
assert file_new.exists() assert file_new.exists()
@ -328,7 +332,7 @@ def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base):
convert_from='jsongz', convert_from='jsongz',
convert_to='json', convert_to='json',
erase=True, erase=True,
candle_type=CandleType.SPOT candle_type=candletype
) )
assert file_temp.exists() assert file_temp.exists()

View File

@ -743,7 +743,7 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
# 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/USDT', '1h', 'mark'), ('UNITTEST/USDT', '1h', 'mark'),
('XRP/USDT', '1h', ''), ('XRP/USDT', '1h', 'futures'),
('XRP/USDT', '1h', 'mark'), ('XRP/USDT', '1h', 'mark'),
} }

View File

@ -1356,7 +1356,7 @@ def test_list_available_pairs(botclient):
ftbot.config['trading_mode'] = 'futures' ftbot.config['trading_mode'] = 'futures'
rc = client_get( rc = client_get(
client, f"{BASE_URI}/available_pairs?timeframe=1h") client, f"{BASE_URI}/available_pairs?timeframe=1h&candletype=futures")
assert_response(rc) assert_response(rc)
assert rc.json()['length'] == 1 assert rc.json()['length'] == 1
assert rc.json()['pairs'] == ['XRP/USDT'] assert rc.json()['pairs'] == ['XRP/USDT']