import logging from typing import Any, Dict from freqtrade import OperationalException from freqtrade.exchange import (available_exchanges, get_exchange_bad_reason, is_exchange_available, is_exchange_bad, is_exchange_officially_supported) from freqtrade.state import RunMode logger = logging.getLogger(__name__) def check_exchange(config: Dict[str, Any], check_for_bad: bool = True) -> bool: """ Check if the exchange name in the config file is supported by Freqtrade :param check_for_bad: if True, check the exchange against the list of known 'bad' exchanges :return: False if exchange is 'bad', i.e. is known to work with the bot with critical issues or does not work at all, crashes, etc. True otherwise. raises an exception if the exchange if not supported by ccxt and thus is not known for the Freqtrade at all. """ if config['runmode'] in [RunMode.PLOT] and not config.get('exchange', {}).get('name'): # Skip checking exchange in plot mode, since it requires no exchange return True logger.info("Checking exchange...") exchange = config.get('exchange', {}).get('name').lower() if not exchange: raise OperationalException( f'This command requires a configured exchange. You can use either ' f'`--exchange