# Buggy code
def _whitelist_for_active_markets(self, pairlist: List[str]) -> List[str]:
    """
    Check available markets and remove pair from whitelist if necessary
    :param whitelist: the sorted list of pairs the user might want to trade
    :return: the list of pairs the user wants to trade without those unavailable or
    black_listed
    """
    markets = self._exchange.markets

    sanitized_whitelist: List[str] = []
    for pair in pairlist:
        # pair is not in the generated dynamic market or has the wrong stake currency
        if pair not in markets:
            logger.warning(
                f"Pair {pair} is not compatible with exchange "
                f"{self._exchange.name}. Removing it from whitelist.."
            )
            continue

        if (
            self._exchange.get_pair_quote_currency(pair)
            != self._config["stake_currency"]
        ):
            logger.warning(
                f"Pair {pair} is not compatible with your stake currency "
                f"{self._config['stake_currency']}. Removing it from whitelist.."
            )
            continue

        # Check if market is active
        market = markets[pair]
        if not market_is_active(market):
            logger.info(f"Ignoring {pair} from whitelist. Market is not active.")
            continue
        if pair not in sanitized_whitelist:
            sanitized_whitelist.append(pair)

    # We need to remove pairs that are unknown
    return sanitized_whitelist


# Traceback (TypeError)
$ freqtrade test-pairlist -c config_kraken.json
2020-06-09 12:46:47,312 - freqtrade.loggers - INFO - Verbosity set to 0
2020-06-09 12:46:47,312 - freqtrade.configuration.configuration - INFO - Using user-data directory: /home/user/freqtrade-wrk/github-hroff-1902/freqtrade/user_data ...
2020-06-09 12:46:47,313 - freqtrade.configuration.configuration - INFO - Using data directory: /home/user/freqtrade-wrk/github-hroff-1902/freqtrade/user_data/data/kraken ...
2020-06-09 12:46:47,313 - freqtrade.configuration.check_exchange - INFO - Checking exchange...
2020-06-09 12:46:47,313 - freqtrade.configuration.check_exchange - INFO - Exchange "kraken" is officially supported by the Freqtrade development team.
2020-06-09 12:46:47,313 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2020-06-09 12:46:47,313 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2020-06-09 12:46:47,315 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2020-06-09 12:46:47,315 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True}
2020-06-09 12:46:47,317 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 3100}
2020-06-09 12:46:47,320 - freqtrade.exchange.exchange - INFO - Using Exchange "Kraken"
2020-06-09 12:46:47,320 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Kraken'...
2020-06-09 12:46:47,324 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/pairlist/StaticPairList.py'...
2020-06-09 12:46:47,324 - freqtrade.exchange.exchange - WARNING - Markets were not loaded. Loading them now..
2020-06-09 12:46:53,817 - freqtrade.exchange.exchange - WARNING - Unable to initialize markets. Reason: GET https://kraken.zendesk.com/api/v2/help_center/en-us/articles/205893708 429 Too Many Requests Number of allowed API requests per minute exceeded
2020-06-09 12:46:53,818 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/main.py", line 36, in main
return_code = args['func'](args)
File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/commands/pairlist_commands.py", line 30, in start_test_pairlist
pairlists.refresh_pairlist()
File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/pairlist/pairlistmanager.py", line 91, in refresh_pairlist
pairlist = self._pairlist_handlers[0].gen_pairlist(self._whitelist, tickers)
File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/pairlist/StaticPairList.py", line 50, in gen_pairlist
return self._whitelist_for_active_markets(self._config['exchange']['pair_whitelist'])
File "/home/user/freqtrade-wrk/github-hroff-1902/freqtrade/freqtrade/pairlist/IPairList.py", line 157, in _whitelist_for_active_markets
if pair not in markets:
TypeError: argument of type 'NoneType' is not iterable

# Fixed code
def _whitelist_for_active_markets(self, pairlist: List[str]) -> List[str]:
    """
    Check available markets and remove pair from whitelist if necessary
    :param whitelist: the sorted list of pairs the user might want to trade
    :return: the list of pairs the user wants to trade without those unavailable or
    black_listed
    """
    markets = self._exchange.markets
    if not markets:
        raise OperationalException(
            "Markets not loaded. Make sure that exchange is initialized correctly."
        )

    sanitized_whitelist: List[str] = []
    for pair in pairlist:
        # pair is not in the generated dynamic market or has the wrong stake currency
        if pair not in markets:
            logger.warning(
                f"Pair {pair} is not compatible with exchange "
                f"{self._exchange.name}. Removing it from whitelist.."
            )
            continue

        if (
            self._exchange.get_pair_quote_currency(pair)
            != self._config["stake_currency"]
        ):
            logger.warning(
                f"Pair {pair} is not compatible with your stake currency "
                f"{self._config['stake_currency']}. Removing it from whitelist.."
            )
            continue

        # Check if market is active
        market = markets[pair]
        if not market_is_active(market):
            logger.info(f"Ignoring {pair} from whitelist. Market is not active.")
            continue
        if pair not in sanitized_whitelist:
            sanitized_whitelist.append(pair)

    # We need to remove pairs that are unknown
    return sanitized_whitelist