# Buggy code
def calculate(self) -> bool:
    pairs = self.config["exchange"]["pair_whitelist"]
    heartbeat = self.edge_config.get("process_throttle_secs")

    if (self._last_updated > 0) and (
        self._last_updated + heartbeat > arrow.utcnow().timestamp
    ):
        return False

    data: Dict[str, Any] = {}
    logger.info("Using stake_currency: %s ...", self.config["stake_currency"])
    logger.info("Using local backtesting data (using whitelist in given config) ...")

    if self._refresh_pairs:
        history.refresh_data(
            datadir=self.config["datadir"],
            pairs=pairs,
            exchange=self.exchange,
            timeframe=self.strategy.ticker_interval,
            timerange=self._timerange,
        )

    data = history.load_data(
        datadir=self.config["datadir"],
        pairs=pairs,
        timeframe=self.strategy.ticker_interval,
        timerange=self._timerange,
        startup_candles=self.strategy.startup_candle_count,
    )

    if not data:
        # Reinitializing cached pairs
        self._cached_pairs = {}
        logger.critical("No data found. Edge is stopped ...")
        return False

    preprocessed = self.strategy.tickerdata_to_dataframe(data)

    # Print timeframe
    min_date, max_date = history.get_timerange(preprocessed)
    logger.info(
        "Measuring data from %s up to %s (%s days) ...",
        min_date.isoformat(),
        max_date.isoformat(),
        (max_date - min_date).days,
    )
    headers = ["date", "buy", "open", "close", "sell", "high", "low"]

    trades: list = []
    for pair, pair_data in preprocessed.items():
        # Sorting dataframe by date and reset index
        pair_data = pair_data.sort_values(by=["date"])
        pair_data = pair_data.reset_index(drop=True)

        ticker_data = self.strategy.advise_sell(
            self.strategy.advise_buy(pair_data, {"pair": pair}), {"pair": pair}
        )[headers].copy()

        trades += self._find_trades_for_stoploss_range(
            ticker_data, pair, self._stoploss_range
        )

    # If no trade found then exit
    if len(trades) == 0:
        logger.info("No trades found.")
        return False

    # Fill missing, calculable columns, profit, duration , abs etc.
    trades_df = self._fill_calculable_fields(DataFrame(trades))
    self._cached_pairs = self._process_expectancy(trades_df)
    self._last_updated = arrow.utcnow().timestamp

    return True


# 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 calculate(self) -> bool:
    pairs = self.config["exchange"]["pair_whitelist"]
    heartbeat = self.edge_config.get("process_throttle_secs")

    if (self._last_updated > 0) and (
        self._last_updated + heartbeat > arrow.utcnow().timestamp
    ):
        return False

    data: Dict[str, Any] = {}
    logger.info("Using stake_currency: %s ...", self.config["stake_currency"])
    logger.info("Using local backtesting data (using whitelist in given config) ...")

    if self._refresh_pairs:
        history.refresh_data(
            datadir=self.config["datadir"],
            pairs=pairs,
            exchange=self.exchange,
            timeframe=self.strategy.ticker_interval,
            timerange=self._timerange,
        )

    data = history.load_data(
        datadir=self.config["datadir"],
        pairs=pairs,
        timeframe=self.strategy.ticker_interval,
        timerange=self._timerange,
        startup_candles=self.strategy.startup_candle_count,
        data_format=self.config.get("dataformat_ohlcv", "json"),
    )

    if not data:
        # Reinitializing cached pairs
        self._cached_pairs = {}
        logger.critical("No data found. Edge is stopped ...")
        return False

    preprocessed = self.strategy.tickerdata_to_dataframe(data)

    # Print timeframe
    min_date, max_date = history.get_timerange(preprocessed)
    logger.info(
        "Measuring data from %s up to %s (%s days) ...",
        min_date.isoformat(),
        max_date.isoformat(),
        (max_date - min_date).days,
    )
    headers = ["date", "buy", "open", "close", "sell", "high", "low"]

    trades: list = []
    for pair, pair_data in preprocessed.items():
        # Sorting dataframe by date and reset index
        pair_data = pair_data.sort_values(by=["date"])
        pair_data = pair_data.reset_index(drop=True)

        ticker_data = self.strategy.advise_sell(
            self.strategy.advise_buy(pair_data, {"pair": pair}), {"pair": pair}
        )[headers].copy()

        trades += self._find_trades_for_stoploss_range(
            ticker_data, pair, self._stoploss_range
        )

    # If no trade found then exit
    if len(trades) == 0:
        logger.info("No trades found.")
        return False

    # Fill missing, calculable columns, profit, duration , abs etc.
    trades_df = self._fill_calculable_fields(DataFrame(trades))
    self._cached_pairs = self._process_expectancy(trades_df)
    self._last_updated = arrow.utcnow().timestamp

    return True