From 1fc97a8008a6ec274acaf085e46a9b0a30cb9ac4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 13 Jan 2023 21:16:19 +0100 Subject: [PATCH] use Unified futures naming for futures throughout tests --- tests/data/test_converter.py | 5 ++++- tests/data/test_datahandler.py | 4 ++-- tests/data/test_history.py | 4 ++-- tests/exchange/test_binance.py | 12 +++++------ tests/exchange/test_exchange.py | 36 ++++++++++++++++----------------- tests/exchange/test_okx.py | 10 ++++----- 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/tests/data/test_converter.py b/tests/data/test_converter.py index ba0a362a0..b37a2100d 100644 --- a/tests/data/test_converter.py +++ b/tests/data/test_converter.py @@ -315,7 +315,10 @@ def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base, cand files_new.append(file_new) default_conf['datadir'] = tmpdir1 - default_conf['pairs'] = ['XRP_ETH', 'XRP_USDT', 'UNITTEST_USDT'] + if candletype == CandleType.SPOT: + default_conf['pairs'] = ['XRP/ETH', 'XRP/USDT', 'UNITTEST/USDT'] + else: + default_conf['pairs'] = ['XRP/ETH:ETH', 'XRP/USDT:USDT', 'UNITTEST/USDT:USDT'] default_conf['timeframes'] = ['1m', '5m', '1h'] assert not file_new.exists() diff --git a/tests/data/test_datahandler.py b/tests/data/test_datahandler.py index 1abb3d186..6fa2de534 100644 --- a/tests/data/test_datahandler.py +++ b/tests/data/test_datahandler.py @@ -142,7 +142,7 @@ def test_jsondatahandler_ohlcv_load(testdatadir, caplog): df = dh.ohlcv_load('XRP/ETH', '5m', 'spot') assert len(df) == 712 - df_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', candle_type="mark") + df_mark = dh.ohlcv_load('UNITTEST/USDT:USDT', '1h', candle_type="mark") assert len(df_mark) == 100 df_no_mark = dh.ohlcv_load('UNITTEST/USDT', '1h', 'spot') @@ -424,7 +424,7 @@ def test_hdf5datahandler_ohlcv_load_and_resave( # Data goes from 2018-01-10 - 2018-01-30 ('UNITTEST/BTC', '5m', 'spot', '', '2018-01-15', '2018-01-19'), # Mark data goes from to 2021-11-15 2021-11-19 - ('UNITTEST/USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'), + ('UNITTEST/USDT:USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'), ]) @pytest.mark.parametrize('datahandler', ['hdf5', 'feather', 'parquet']) def test_generic_datahandler_ohlcv_load_and_resave( diff --git a/tests/data/test_history.py b/tests/data/test_history.py index b985666cc..7d313c446 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -78,11 +78,11 @@ def test_load_data_1min_timeframe(ohlcv_history, mocker, caplog, testdatadir) -> def test_load_data_mark(ohlcv_history, mocker, caplog, testdatadir) -> None: mocker.patch('freqtrade.exchange.Exchange.get_historic_ohlcv', return_value=ohlcv_history) - file = testdatadir / 'futures/UNITTEST_USDT-1h-mark.json' + file = testdatadir / 'futures/UNITTEST_USDT_USDT-1h-mark.json' load_data(datadir=testdatadir, timeframe='1h', pairs=['UNITTEST/BTC'], candle_type='mark') assert file.is_file() assert not log_has( - 'Download history data for pair: "UNITTEST/USDT", interval: 1m ' + 'Download history data for pair: "UNITTEST/USDT:USDT", interval: 1m ' 'and store in None.', caplog ) diff --git a/tests/exchange/test_binance.py b/tests/exchange/test_binance.py index 68e448ab2..cb304f699 100644 --- a/tests/exchange/test_binance.py +++ b/tests/exchange/test_binance.py @@ -576,12 +576,12 @@ async def test__async_get_historic_ohlcv_binance(default_conf, mocker, caplog, c @pytest.mark.parametrize('pair,nominal_value,mm_ratio,amt', [ - ("BNB/BUSD", 0.0, 0.025, 0), - ("BNB/USDT", 100.0, 0.0065, 0), - ("BTC/USDT", 170.30, 0.004, 0), - ("BNB/BUSD", 999999.9, 0.1, 27500.0), - ("BNB/USDT", 5000000.0, 0.15, 233035.0), - ("BTC/USDT", 600000000, 0.5, 1.997038E8), + ("BNB/BUSD:BUSD", 0.0, 0.025, 0), + ("BNB/USDT:USDT", 100.0, 0.0065, 0), + ("BTC/USDT:USDT", 170.30, 0.004, 0), + ("BNB/BUSD:BUSD", 999999.9, 0.1, 27500.0), + ("BNB/USDT:USDT", 5000000.0, 0.15, 233035.0), + ("BTC/USDT:USDT", 600000000, 0.5, 1.997038E8), ]) def test_get_maintenance_ratio_and_amt_binance( default_conf, diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 16212e413..0fa7f90ec 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -4898,22 +4898,22 @@ def test_get_maintenance_ratio_and_amt_exceptions(mocker, default_conf, leverage OperationalException, match='nominal value can not be lower than 0', ): - exchange.get_maintenance_ratio_and_amt('1000SHIB/USDT', -1) + exchange.get_maintenance_ratio_and_amt('1000SHIB/USDT:USDT', -1) exchange._leverage_tiers = {} with pytest.raises( InvalidOrderException, - match="Maintenance margin rate for 1000SHIB/USDT is unavailable for", + match="Maintenance margin rate for 1000SHIB/USDT:USDT is unavailable for", ): - exchange.get_maintenance_ratio_and_amt('1000SHIB/USDT', 10000) + exchange.get_maintenance_ratio_and_amt('1000SHIB/USDT:USDT', 10000) @pytest.mark.parametrize('pair,value,mmr,maintAmt', [ - ('ADA/BUSD', 500, 0.025, 0.0), - ('ADA/BUSD', 20000000, 0.5, 1527500.0), - ('ZEC/USDT', 500, 0.01, 0.0), - ('ZEC/USDT', 20000000, 0.5, 654500.0), + ('ADA/BUSD:BUSD', 500, 0.025, 0.0), + ('ADA/BUSD:BUSD', 20000000, 0.5, 1527500.0), + ('ZEC/USDT:USDT', 500, 0.01, 0.0), + ('ZEC/USDT:USDT', 20000000, 0.5, 654500.0), ]) def test_get_maintenance_ratio_and_amt( mocker, @@ -4946,21 +4946,21 @@ def test_get_max_leverage_futures(default_conf, mocker, leverage_tiers): exchange._leverage_tiers = leverage_tiers - assert exchange.get_max_leverage("BNB/BUSD", 1.0) == 20.0 - assert exchange.get_max_leverage("BNB/USDT", 100.0) == 75.0 - assert exchange.get_max_leverage("BTC/USDT", 170.30) == 125.0 - assert pytest.approx(exchange.get_max_leverage("BNB/BUSD", 99999.9)) == 5.000005 - assert pytest.approx(exchange.get_max_leverage("BNB/USDT", 1500)) == 33.333333333333333 - assert exchange.get_max_leverage("BTC/USDT", 300000000) == 2.0 - assert exchange.get_max_leverage("BTC/USDT", 600000000) == 1.0 # Last tier + assert exchange.get_max_leverage("BNB/BUSD:BUSD", 1.0) == 20.0 + assert exchange.get_max_leverage("BNB/USDT:USDT", 100.0) == 75.0 + assert exchange.get_max_leverage("BTC/USDT:USDT", 170.30) == 125.0 + assert pytest.approx(exchange.get_max_leverage("BNB/BUSD:BUSD", 99999.9)) == 5.000005 + assert pytest.approx(exchange.get_max_leverage("BNB/USDT:USDT", 1500)) == 33.333333333333333 + assert exchange.get_max_leverage("BTC/USDT:USDT", 300000000) == 2.0 + assert exchange.get_max_leverage("BTC/USDT:USDT", 600000000) == 1.0 # Last tier - assert exchange.get_max_leverage("SPONGE/USDT", 200) == 1.0 # Pair not in leverage_tiers - assert exchange.get_max_leverage("BTC/USDT", 0.0) == 125.0 # No stake amount + assert exchange.get_max_leverage("SPONGE/USDT:USDT", 200) == 1.0 # Pair not in leverage_tiers + assert exchange.get_max_leverage("BTC/USDT:USDT", 0.0) == 125.0 # No stake amount with pytest.raises( InvalidOrderException, - match=r'Amount 1000000000.01 too high for BTC/USDT' + match=r'Amount 1000000000.01 too high for BTC/USDT:USDT' ): - exchange.get_max_leverage("BTC/USDT", 1000000000.01) + exchange.get_max_leverage("BTC/USDT:USDT", 1000000000.01) @pytest.mark.parametrize("exchange_name", ['bittrex', 'binance', 'kraken', 'gateio', 'okx']) diff --git a/tests/exchange/test_okx.py b/tests/exchange/test_okx.py index ac5c81ebb..46b1852a0 100644 --- a/tests/exchange/test_okx.py +++ b/tests/exchange/test_okx.py @@ -195,12 +195,12 @@ def test_get_max_pair_stake_amount_okx(default_conf, mocker, leverage_tiers): exchange = get_patched_exchange(mocker, default_conf, id="okx") exchange._leverage_tiers = leverage_tiers - assert exchange.get_max_pair_stake_amount('BNB/BUSD', 1.0) == 30000000 - assert exchange.get_max_pair_stake_amount('BNB/USDT', 1.0) == 50000000 - assert exchange.get_max_pair_stake_amount('BTC/USDT', 1.0) == 1000000000 - assert exchange.get_max_pair_stake_amount('BTC/USDT', 1.0, 10.0) == 100000000 + assert exchange.get_max_pair_stake_amount('BNB/BUSD:BUSD', 1.0) == 30000000 + assert exchange.get_max_pair_stake_amount('BNB/USDT:USDT', 1.0) == 50000000 + assert exchange.get_max_pair_stake_amount('BTC/USDT:USDT', 1.0) == 1000000000 + assert exchange.get_max_pair_stake_amount('BTC/USDT:USDT', 1.0, 10.0) == 100000000 - assert exchange.get_max_pair_stake_amount('TTT/USDT', 1.0) == float('inf') # Not in tiers + assert exchange.get_max_pair_stake_amount('TTT/USDT:USDT', 1.0) == float('inf') # Not in tiers @pytest.mark.parametrize('mode,side,reduceonly,result', [