diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index a5c10776c..3735dac8a 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -216,8 +216,9 @@ class Exchange: Return a list of supported quote currencies """ markets = self.markets - currencies = set([x.get('quote') for _, x in markets.items()]) - return list(currencies) + currencies = list(set([x.get('quote') for _, x in markets.items()])) + currencies.sort() + return currencies def klines(self, pair_interval: Tuple[str, str], copy=True) -> DataFrame: if pair_interval in self._klines: @@ -277,8 +278,8 @@ class Exchange: quote_currencies = self.get_quote_currencies() if stake_currency not in quote_currencies: raise OperationalException( - f"{stake_currency} is not available as stake on {self.name}." - f"Available currencies are: {','.join(quote_currencies)}") + f"{stake_currency} is not available as stake on {self.name}. " + f"Available currencies are: {', '.join(quote_currencies)}") def validate_pairs(self, pairs: List[str]) -> None: """ diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 5924d4b40..150ba3ea7 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -333,6 +333,23 @@ def test_validate_stake_currency(default_conf, stake_currency, mocker, caplog): Exchange(default_conf) +def test_validate_stake_currency_error(default_conf, mocker, caplog): + default_conf['stake_currency'] = 'XRP' + api_mock = MagicMock() + type(api_mock).markets = PropertyMock(return_value={ + 'ETH/BTC': {'quote': 'BTC'}, 'LTC/BTC': {'quote': 'BTC'}, + 'XRP/ETH': {'quote': 'ETH'}, 'NEO/USDT': {'quote': 'USDT'}, + }) + mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock)) + mocker.patch('freqtrade.exchange.Exchange.validate_pairs') + mocker.patch('freqtrade.exchange.Exchange.validate_timeframes') + mocker.patch('freqtrade.exchange.Exchange._load_async_markets') + with pytest.raises(OperationalException, + match=r'XRP is not available as stake on .*' + 'Available currencies are: BTC, ETH, USDT'): + Exchange(default_conf) + + def test_get_quote_currencies(default_conf, mocker): ex = get_patched_exchange(mocker, default_conf)