From 5aaab75d1cf177e10cd4ee0bd575084f9a6a2910 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 13 Aug 2022 10:18:57 +0200 Subject: [PATCH] Add test for dynamic_pairlist_expand --- freqtrade/plugins/pairlist/pairlist_helpers.py | 4 ++-- freqtrade/strategy/interface.py | 3 ++- tests/plugins/test_pairlist.py | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/freqtrade/plugins/pairlist/pairlist_helpers.py b/freqtrade/plugins/pairlist/pairlist_helpers.py index f1eca6df0..0cec734fb 100644 --- a/freqtrade/plugins/pairlist/pairlist_helpers.py +++ b/freqtrade/plugins/pairlist/pairlist_helpers.py @@ -1,5 +1,5 @@ import re -from typing import List +from typing import Any, Dict, List def expand_pairlist(wildcardpl: List[str], available_pairs: List[str], @@ -42,7 +42,7 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str], return result -def dynamic_expand_pairlist(config: dict, markets: list) -> List[str]: +def dynamic_expand_pairlist(config: Dict[str, Any], markets: List[str]) -> List[str]: expanded_pairs = expand_pairlist(config['pairs'], markets) if config.get('freqai', {}).get('enabled', False): corr_pairlist = config['freqai']['feature_parameters']['include_corr_pairlist'] diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 45609beaa..f41369189 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -157,7 +157,8 @@ class IStrategy(ABC, HyperStrategyMixin): class DummyClass(): def start(self, *args, **kwargs): raise OperationalException( - 'freqAI is not enabled. Please enable it in your config to use this strategy.') + 'freqAI is not enabled. ' + 'Please enable it in your config to use this strategy.') self.freqai = DummyClass() # type: ignore def ft_bot_start(self, **kwargs) -> None: diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index c56f405e2..d3d08dc8c 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -12,7 +12,7 @@ from freqtrade.constants import AVAILABLE_PAIRLISTS from freqtrade.enums import CandleType, RunMode from freqtrade.exceptions import OperationalException from freqtrade.persistence import Trade -from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist +from freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist, expand_pairlist from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.resolvers import PairListResolver from tests.conftest import (create_mock_trades_usdt, get_patched_exchange, get_patched_freqtradebot, @@ -1282,6 +1282,22 @@ def test_expand_pairlist(wildcardlist, pairs, expected): expand_pairlist(wildcardlist, pairs) else: assert sorted(expand_pairlist(wildcardlist, pairs)) == sorted(expected) + conf = { + 'pairs': wildcardlist, + 'freqai': { + "enabled": True, + "feature_parameters": { + "include_corr_pairlist": [ + "BTC/USDT:USDT", + "XRP/BUSD", + ] + } + } + } + assert sorted(dynamic_expand_pairlist(conf, pairs)) == sorted(expected + [ + "BTC/USDT:USDT", + "XRP/BUSD", + ]) @pytest.mark.parametrize('wildcardlist,pairs,expected', [