From be70c4f959b76bc40ccfc774a5c3e2f738c75baa Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Wed, 3 Jul 2019 12:50:27 +0300 Subject: [PATCH] handle empty markets from ccxt --- freqtrade/exchange/exchange.py | 18 ++++++++++-------- freqtrade/utils.py | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 521be7b71..7f14b8043 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -208,14 +208,16 @@ class Exchange(object): if this was requested in parameters. """ markets = self.markets - if base_currency: - markets = {k: v for k, v in markets.items() if v['base'] == base_currency} - if quote_currency: - markets = {k: v for k, v in markets.items() if v['quote'] == quote_currency} - if pairs_only: - markets = {k: v for k, v in markets.items() if symbol_is_pair(v['symbol'])} - if active_only: - markets = {k: v for k, v in markets.items() if v['active']} + if markets is not None: + if base_currency: + markets = {k: v for k, v in markets.items() if v['base'] == base_currency} + if quote_currency: + markets = {k: v for k, v in markets.items() if v['quote'] == quote_currency} + if pairs_only: + markets = {k: v for k, v in markets.items() if symbol_is_pair(v['symbol'])} + if active_only: + markets = {k: v for k, v in markets.items() if v['active']} + return markets def klines(self, pair_interval: Tuple[str, str], copy=True) -> DataFrame: diff --git a/freqtrade/utils.py b/freqtrade/utils.py index a73236a0e..7779d3d7b 100644 --- a/freqtrade/utils.py +++ b/freqtrade/utils.py @@ -2,6 +2,7 @@ import logging from argparse import Namespace from typing import Any, Dict +from freqtrade import OperationalException from freqtrade.configuration import Configuration from freqtrade.exchange import available_exchanges, Exchange from freqtrade.misc import plural @@ -67,6 +68,9 @@ def start_list_pairs(args: Namespace, pairs_only: bool = False) -> None: pairs_only=pairs_only, active_only=args.active_only) + if pairs is None: + raise OperationalException(f"No markets info available for exchange \"{exchange.name}\"") + if args.print_list: # print data as a list print(f"Exchange {exchange.name} has {len(pairs)} " +