# Buggy code
def _gen_pair_whitelist(
    self, pairlist, tickers, base_currency: str, key: str
) -> List[str]:
    """
    Updates the whitelist with with a dynamically generated list
    :param base_currency: base currency as str
    :param key: sort key (defaults to 'quoteVolume')
    :param tickers: Tickers (from exchange.get_tickers()).
    :return: List of pairs
    """

    if self._pairlist_pos == 0:
        # If VolumePairList is the first in the list, use fresh pairlist
        # check length so that we make sure that '/' is actually in the string
        filtered_tickers = [
            v
            for k, v in tickers.items()
            if (
                len(k.split("/")) == 2
                and k.split("/")[1] == base_currency
                and v[key] is not None
            )
        ]
    else:
        # If other pairlist is in front, use the incomming pairlist.
        filtered_tickers = [v for k, v in tickers.items() if k in pairlist]

    sorted_tickers = sorted(filtered_tickers, reverse=True, key=lambda t: t[key])

    # Validate whitelist to only have active market pairs
    pairs = self._whitelist_for_active_markets([s["symbol"] for s in sorted_tickers])
    pairs = self._verify_blacklist(pairs)
    # Limit to X number of pairs
    pairs = pairs[: self._number_pairs]
    logger.info(f"Searching {self._number_pairs} pairs: {pairs}")

    return pairs


# Traceback (Exception)
2020-02-20 22:47:28,025 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/opt/tradebot/freqtrade/.env/lib/python3.7/site-packages/talib/__init__.py", line 20, in wrapper
for arg in chain(args, kwargs.values())
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/freqtrade/freqtrade/main.py", line 36, in main
return_code = args['func'](args)
File "/freqtrade/freqtrade/commands/optimize_commands.py", line 76, in start_hyperopt
hyperopt.start()
File "/freqtrade/freqtrade/optimize/hyperopt.py", line 488, in start
preprocessed = self.backtesting.strategy.tickerdata_to_dataframe(data)
File "/freqtrade/freqtrade/strategy/interface.py", line 448, in tickerdata_to_dataframe
for pair, pair_data in tickerdata.items()}
File "/freqtrade/freqtrade/strategy/interface.py", line 448, in <dictcomp>
for pair, pair_data in tickerdata.items()}
File "/freqtrade/freqtrade/strategy/interface.py", line 464, in advise_indicators
return self.populate_indicators(dataframe, metadata)
File "/freqtrade/user_data/strategies/MyDev.py", line 205, in populate_indicators
dataframe['mfi'] = ta.MFI(dataframe)
File "talib/_abstract.pxi", line 352, in talib._ta_lib.Function.__call__
File "talib/_abstract.pxi", line 383, in talib._ta_lib.Function.__call_function
File "/opt/tradebot/freqtrade/.env/lib/python3.7/site-packages/talib/__init__.py", line 24, in wrapper
return func(*args, **kwargs)
File "talib/_func.pxi", line 8454, in talib._ta_lib.MFI
Exception: volume is not double

# Fixed code
def _gen_pair_whitelist(
    self, pairlist: List[str], tickers: Dict, base_currency: str, key: str, min_val: int
) -> List[str]:
    """
    Updates the whitelist with with a dynamically generated list
    :param base_currency: base currency as str
    :param key: sort key (defaults to 'quoteVolume')
    :param tickers: Tickers (from exchange.get_tickers()).
    :return: List of pairs
    """

    if self._pairlist_pos == 0:
        # If VolumePairList is the first in the list, use fresh pairlist
        # check length so that we make sure that '/' is actually in the string
        filtered_tickers = [
            v
            for k, v in tickers.items()
            if (
                len(k.split("/")) == 2
                and k.split("/")[1] == base_currency
                and v[key] is not None
            )
        ]
    else:
        # If other pairlist is in front, use the incomming pairlist.
        filtered_tickers = [v for k, v in tickers.items() if k in pairlist]

    if min_val > 0:
        filtered_tickers = list(filter(lambda t: t[key] > min_val, filtered_tickers))

    sorted_tickers = sorted(filtered_tickers, reverse=True, key=lambda t: t[key])

    # Validate whitelist to only have active market pairs
    pairs = self._whitelist_for_active_markets([s["symbol"] for s in sorted_tickers])
    pairs = self._verify_blacklist(pairs)
    # Limit to X number of pairs
    pairs = pairs[: self._number_pairs]
    logger.info(f"Searching {self._number_pairs} pairs: {pairs}")

    return pairs