Add test for dynamic_pairlist_expand

This commit is contained in:
Matthias 2022-08-13 10:18:57 +02:00
parent 1ac6ec1446
commit 5aaab75d1c
3 changed files with 21 additions and 4 deletions

View File

@ -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']

View File

@ -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:

View File

@ -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', [