diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index 8bf3d41f1..98df84b7d 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -265,7 +265,7 @@ def list_available_pairs(timeframe: Optional[str] = None, stake_currency: Option if candletype: pair_interval = [pair for pair in pair_interval if pair[2] == candletype] else: - pair_interval = [pair for pair in pair_interval if pair[2] == ''] + pair_interval = [pair for pair in pair_interval if pair[2] == CandleType.SPOT_] pair_interval = sorted(pair_interval, key=lambda x: x[0]) diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 6fa62ab0c..b95757561 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -720,17 +720,17 @@ def test_datahandler_ohlcv_get_available_data(testdatadir): paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, 'spot') # Convert to set to avoid failures due to sorting assert set(paircombs) == { - ('UNITTEST/BTC', '5m', ''), - ('ETH/BTC', '5m', ''), - ('XLM/BTC', '5m', ''), - ('TRX/BTC', '5m', ''), - ('LTC/BTC', '5m', ''), - ('XMR/BTC', '5m', ''), - ('ZEC/BTC', '5m', ''), - ('UNITTEST/BTC', '1m', ''), - ('ADA/BTC', '5m', ''), - ('ETC/BTC', '5m', ''), - ('NXT/BTC', '5m', ''), + ('UNITTEST/BTC', '5m', CandleType.SPOT_), + ('ETH/BTC', '5m', CandleType.SPOT_), + ('XLM/BTC', '5m', CandleType.SPOT_), + ('TRX/BTC', '5m', CandleType.SPOT_), + ('LTC/BTC', '5m', CandleType.SPOT_), + ('XMR/BTC', '5m', CandleType.SPOT_), + ('ZEC/BTC', '5m', CandleType.SPOT_), + ('UNITTEST/BTC', '1m', CandleType.SPOT_), + ('ADA/BTC', '5m', CandleType.SPOT_), + ('ETC/BTC', '5m', CandleType.SPOT_), + ('NXT/BTC', '5m', CandleType.SPOT_), ('DASH/BTC', '5m', ''), ('XRP/ETH', '1m', ''), ('XRP/ETH', '5m', ''), diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index 4110ca95c..fe375a671 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -7,6 +7,7 @@ import pytest import time_machine from freqtrade.constants import AVAILABLE_PAIRLISTS +from freqtrade.enums.candletype import CandleType from freqtrade.enums.runmode import RunMode from freqtrade.exceptions import OperationalException from freqtrade.persistence import Trade @@ -461,11 +462,11 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t ohlcv_history_high_vola.loc[ohlcv_history_high_vola.index == 1, 'close'] = 0.00090 ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history.append(ohlcv_history), - ('XRP/BTC', '1d', ''): ohlcv_history, - ('HOT/BTC', '1d', ''): ohlcv_history_high_vola, + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history.append(ohlcv_history), + ('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola, } mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) @@ -579,11 +580,11 @@ def test_VolumePairList_range(mocker, whitelist_conf, shitcoinmarkets, tickers, ohlcv_history_high_volume.loc[:, 'volume'] = 10 ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history_medium_volume, - ('XRP/BTC', '1d', ''): ohlcv_history_high_vola, - ('HOT/BTC', '1d', ''): ohlcv_history_high_volume, + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history_medium_volume, + ('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola, + ('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_volume, } mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) @@ -855,9 +856,9 @@ def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tick def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, ohlcv_history): with time_machine.travel("2021-09-01 05:00:00 +00:00") as t: ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history, + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, } mocker.patch.multiple( 'freqtrade.exchange.Exchange', @@ -879,10 +880,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o assert freqtrade.exchange.refresh_latest_ohlcv.call_count == 2 ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history, - ('XRP/BTC', '1d', ''): ohlcv_history.iloc[[0]], + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history.iloc[[0]], } mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data) freqtrade.pairlists.refresh_pairlist() @@ -900,10 +901,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o t.move_to("2021-09-03 01:00:00 +00:00") # Called once for XRP/BTC ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history, - ('XRP/BTC', '1d', ''): ohlcv_history, + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, } mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data) freqtrade.pairlists.refresh_pairlist() @@ -964,12 +965,12 @@ def test_rangestabilityfilter_caching(mocker, markets, default_conf, tickers, oh get_tickers=tickers ) ohlcv_data = { - ('ETH/BTC', '1d', ''): ohlcv_history, - ('TKN/BTC', '1d', ''): ohlcv_history, - ('LTC/BTC', '1d', ''): ohlcv_history, - ('XRP/BTC', '1d', ''): ohlcv_history, - ('HOT/BTC', '1d', ''): ohlcv_history, - ('BLK/BTC', '1d', ''): ohlcv_history, + ('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history, + ('BLK/BTC', '1d', CandleType.SPOT_): ohlcv_history, } mocker.patch.multiple( 'freqtrade.exchange.Exchange', diff --git a/tests/strategy/test_strategy_helpers.py b/tests/strategy/test_strategy_helpers.py index e7019b767..08fb3563e 100644 --- a/tests/strategy/test_strategy_helpers.py +++ b/tests/strategy/test_strategy_helpers.py @@ -5,6 +5,7 @@ import pandas as pd import pytest from freqtrade.data.dataprovider import DataProvider +from freqtrade.enums.candletype import CandleType from freqtrade.strategy import (merge_informative_pair, stoploss_from_absolute, stoploss_from_open, timeframe_to_minutes) from tests.conftest import get_patched_exchange @@ -151,18 +152,18 @@ def test_informative_decorator(mocker, default_conf): test_data_30m = generate_test_data('30m', 40) test_data_1h = generate_test_data('1h', 40) data = { - ('XRP/USDT', '5m', ''): test_data_5m, - ('XRP/USDT', '30m', ''): test_data_30m, - ('XRP/USDT', '1h', ''): test_data_1h, - ('LTC/USDT', '5m', ''): test_data_5m, - ('LTC/USDT', '30m', ''): test_data_30m, - ('LTC/USDT', '1h', ''): test_data_1h, - ('NEO/USDT', '30m', ''): test_data_30m, - ('NEO/USDT', '5m', ''): test_data_5m, - ('NEO/USDT', '1h', ''): test_data_1h, - ('ETH/USDT', '1h', ''): test_data_1h, - ('ETH/USDT', '30m', ''): test_data_30m, - ('ETH/BTC', '1h', ''): test_data_1h, + ('XRP/USDT', '5m', CandleType.SPOT_): test_data_5m, + ('XRP/USDT', '30m', CandleType.SPOT_): test_data_30m, + ('XRP/USDT', '1h', CandleType.SPOT_): test_data_1h, + ('LTC/USDT', '5m', CandleType.SPOT_): test_data_5m, + ('LTC/USDT', '30m', CandleType.SPOT_): test_data_30m, + ('LTC/USDT', '1h', CandleType.SPOT_): test_data_1h, + ('NEO/USDT', '30m', CandleType.SPOT_): test_data_30m, + ('NEO/USDT', '5m', CandleType.SPOT_): test_data_5m, + ('NEO/USDT', '1h', CandleType.SPOT_): test_data_1h, + ('ETH/USDT', '1h', CandleType.SPOT_): test_data_1h, + ('ETH/USDT', '30m', CandleType.SPOT_): test_data_30m, + ('ETH/BTC', '1h', CandleType.SPOT_): test_data_1h, } from .strats.informative_decorator_strategy import InformativeDecoratorTest default_conf['stake_currency'] = 'USDT' @@ -174,9 +175,16 @@ def test_informative_decorator(mocker, default_conf): ]) assert len(strategy._ft_informative) == 6 # Equal to number of decorators used - informative_pairs = [('XRP/USDT', '1h', ''), ('LTC/USDT', '1h', ''), ('XRP/USDT', '30m', ''), - ('LTC/USDT', '30m', ''), ('NEO/USDT', '1h', ''), ('NEO/USDT', '30m', ''), - ('NEO/USDT', '5m', ''), ('ETH/BTC', '1h', ''), ('ETH/USDT', '30m', '')] + informative_pairs = [ + ('XRP/USDT', '1h', CandleType.SPOT_), + ('LTC/USDT', '1h', CandleType.SPOT_), + ('XRP/USDT', '30m', CandleType.SPOT_), + ('LTC/USDT', '30m', CandleType.SPOT_), + ('NEO/USDT', '1h', CandleType.SPOT_), + ('NEO/USDT', '30m', CandleType.SPOT_), + ('NEO/USDT', '5m', CandleType.SPOT_), + ('ETH/BTC', '1h', CandleType.SPOT_), + ('ETH/USDT', '30m', CandleType.SPOT_)] for inf_pair in informative_pairs: assert inf_pair in strategy.gather_informative_pairs() @@ -186,7 +194,7 @@ def test_informative_decorator(mocker, default_conf): side_effect=test_historic_ohlcv) analyzed = strategy.advise_all_indicators( - {p: data[(p, strategy.timeframe, '')] for p in ('XRP/USDT', 'LTC/USDT')}) + {p: data[(p, strategy.timeframe, CandleType.SPOT_)] for p in ('XRP/USDT', 'LTC/USDT')}) expected_columns = [ 'rsi_1h', 'rsi_30m', # Stacked informative decorators 'neo_usdt_rsi_1h', # NEO 1h informative