From 7a79b292e46dfab4e19e4635c8720bac8cde7676 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 17 Aug 2019 07:05:42 +0200 Subject: [PATCH] Fix bug in pairs fallback resolving --- freqtrade/configuration/configuration.py | 3 ++- freqtrade/tests/test_configuration.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index c51153f4b..676b0c594 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -380,7 +380,7 @@ class Configuration(object): config['pairs'].sort() return - if "config" in self.args: + if "config" in self.args and self.args.config: logger.info("Using pairlist from configuration.") config['pairs'] = config.get('exchange', {}).get('pair_whitelist') else: @@ -388,3 +388,4 @@ class Configuration(object): pairs_file = Path(config['datadir']) / "pairs.json" if pairs_file.exists(): config['pairs'] = json_load(pairs_file) + config['pairs'].sort() diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index c351b9b72..b6e8a76d9 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -792,3 +792,21 @@ def test_pairlist_resolving_with_config_pl_not_exists(mocker, default_conf): with pytest.raises(OperationalException, match=r"No pairs file found with path.*"): configuration = Configuration(args) configuration.get_config() + + +def test_pairlist_resolving_fallback(mocker): + mocker.patch.object(Path, "exists", MagicMock(return_value=True)) + mocker.patch("freqtrade.configuration.configuration.json_load", + MagicMock(return_value=['XRP/BTC', 'ETH/BTC'])) + arglist = [ + 'download-data', + '--exchange', 'binance' + ] + + args = Arguments(arglist, '').get_parsed_arg() + + configuration = Configuration(args) + config = configuration.get_config() + + assert config['pairs'] == ['ETH/BTC', 'XRP/BTC'] + assert config['exchange']['name'] == 'binance'