From bb9235c7155dbd562c001e3935a7791629d3f846 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 7 Dec 2019 15:42:47 +0100 Subject: [PATCH] Validate stake-currency against pairlist - making sure only correct pairs are in the whitelist --- freqtrade/configuration/config_validation.py | 7 +++++++ tests/test_configuration.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/freqtrade/configuration/config_validation.py b/freqtrade/configuration/config_validation.py index 4bfd24677..ca0e01ba0 100644 --- a/freqtrade/configuration/config_validation.py +++ b/freqtrade/configuration/config_validation.py @@ -131,3 +131,10 @@ def _validate_whitelist(conf: Dict[str, Any]) -> None: if (pl.get('method') == 'StaticPairList' and not conf.get('exchange', {}).get('pair_whitelist')): raise OperationalException("StaticPairList requires pair_whitelist to be set.") + + if pl.get('method') == 'StaticPairList': + stake = conf['stake_currency'] + pairlist = conf['exchange'].get('pair_whitelist') + if not all([p.endswith(f'/{stake}') for p in pairlist]): + raise OperationalException( + f"Stake-currency {stake} not compatible with pair-whitelist.") diff --git a/tests/test_configuration.py b/tests/test_configuration.py index ae85c7493..7f708934b 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -798,6 +798,12 @@ def test_validate_whitelist(default_conf): validate_config_consistency(conf) + conf = deepcopy(default_conf) + conf['stake_currency'] = 'USDT' + with pytest.raises(OperationalException, + match="Stake-currency USDT not compatible with pair-whitelist."): + validate_config_consistency(conf) + def test_load_config_test_comments() -> None: """