gurudesh/pytracebugs huggingface dataset:
# Buggy code
def __init__(
    self, exchange, pairlistmanager, config, pairlistconfig: dict, pairlist_pos: int
) -> None:
    super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)

    self._low_price_ratio = pairlistconfig.get("low_price_ratio", 0)


# 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 __init__(
    self,
    exchange,
    pairlistmanager,
    config: Dict[str, Any],
    pairlistconfig: Dict[str, Any],
    pairlist_pos: int,
) -> None:
    super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)

    self._low_price_ratio = pairlistconfig.get("low_price_ratio", 0)
# Buggy code
def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
    """
    Filters and sorts pairlist and returns the whitelist again.
    Called on each bot iteration - please use internal caching if necessary
    :param pairlist: pairlist to filter or sort
    :param tickers: Tickers (from exchange.get_tickers()). May be cached.
    :return: new whitelist
    """
    # Generate dynamic whitelist
    if self._last_refresh + self.refresh_period < datetime.now().timestamp():
        self._last_refresh = int(datetime.now().timestamp())
        return self._gen_pair_whitelist(
            pairlist,
            tickers,
            self._config["stake_currency"],
            self._sort_key,
        )
    else:
        return pairlist


# 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 filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
    """
    Filters and sorts pairlist and returns the whitelist again.
    Called on each bot iteration - please use internal caching if necessary
    :param pairlist: pairlist to filter or sort
    :param tickers: Tickers (from exchange.get_tickers()). May be cached.
    :return: new whitelist
    """
    # Generate dynamic whitelist
    if self._last_refresh + self.refresh_period < datetime.now().timestamp():
        self._last_refresh = int(datetime.now().timestamp())
        return self._gen_pair_whitelist(
            pairlist,
            tickers,
            self._config["stake_currency"],
            self._sort_key,
            self._min_value,
        )
    else:
        return pairlist
# Buggy code
def has_column(columns, searchname: str) -> bool:
    return len(list(filter(lambda x: x["name"] == searchname, columns))) == 1


# 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 has_column(columns: List, searchname: str) -> bool:
    return len(list(filter(lambda x: x["name"] == searchname, columns))) == 1
# Buggy code
def get_column_def(columns, column: str, default: str) -> str:
    return default if not has_column(columns, column) else column


# 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 get_column_def(columns: List, column: str, default: str) -> str:
    return default if not has_column(columns, column) else column
# Buggy code
def adjust_min_max_rates(self, current_price: float):
    """
    Adjust the max_rate and min_rate.
    """
    self.max_rate = max(current_price, self.max_rate or self.open_rate)
    self.min_rate = min(current_price, self.min_rate or self.open_rate)


# 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 adjust_min_max_rates(self, current_price: float) -> None:
    """
    Adjust the max_rate and min_rate.
    """
    self.max_rate = max(current_price, self.max_rate or self.open_rate)
    self.min_rate = min(current_price, self.min_rate or self.open_rate)
# Buggy code
def generate_plot_filename(pair, timeframe) -> str:
    """
    Generate filenames per pair/timeframe to be used for storing plots
    """
    pair_name = pair.replace("/", "_")
    file_name = "freqtrade-plot-" + pair_name + "-" + timeframe + ".html"

    logger.info("Generate plot file for %s", pair)

    return file_name


# 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 generate_plot_filename(pair: str, timeframe: str) -> str:
    """
    Generate filenames per pair/timeframe to be used for storing plots
    """
    pair_s = pair_to_filename(pair)
    file_name = "freqtrade-plot-" + pair_s + "-" + timeframe + ".html"

    logger.info("Generate plot file for %s", pair)

    return file_name
# Buggy code
def build_search_paths(
    cls, config, user_subdir: Optional[str] = None, extra_dir: Optional[str] = None
) -> List[Path]:
    abs_paths: List[Path] = [cls.initial_search_path]

    if user_subdir:
        abs_paths.insert(0, config["user_data_dir"].joinpath(user_subdir))

    if extra_dir:
        # Add extra directory to the top of the search paths
        abs_paths.insert(0, Path(extra_dir).resolve())

    return abs_paths


# 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 build_search_paths(
    cls,
    config: Dict[str, Any],
    user_subdir: Optional[str] = None,
    extra_dir: Optional[str] = None,
) -> List[Path]:
    abs_paths: List[Path] = []
    if cls.initial_search_path:
        abs_paths.append(cls.initial_search_path)

    if user_subdir:
        abs_paths.insert(0, config["user_data_dir"].joinpath(user_subdir))

    if extra_dir:
        # Add extra directory to the top of the search paths
        abs_paths.insert(0, Path(extra_dir).resolve())

    return abs_paths
# Buggy code
def unlock_pair(self, pair) -> None:
    """
    Unlocks a pair previously locked using lock_pair.
    Not used by freqtrade itself, but intended to be used if users lock pairs
    manually from within the strategy, to allow an easy way to unlock pairs.
    :param pair: Unlock pair to allow trading again
    """
    if pair in self._pair_locked_until:
        del self._pair_locked_until[pair]


# 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 unlock_pair(self, pair: str) -> None:
    """
    Unlocks a pair previously locked using lock_pair.
    Not used by freqtrade itself, but intended to be used if users lock pairs
    manually from within the strategy, to allow an easy way to unlock pairs.
    :param pair: Unlock pair to allow trading again
    """
    if pair in self._pair_locked_until:
        del self._pair_locked_until[pair]
# Buggy code
def tickerdata_to_dataframe(self, tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
    """
    Creates a dataframe and populates indicators for given ticker data
    Used by optimize operations only, not during dry / live runs.
    """
    return {
        pair: self.advise_indicators(pair_data, {"pair": pair})
        for pair, pair_data in tickerdata.items()
    }


# 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 tickerdata_to_dataframe(
    self, tickerdata: Dict[str, DataFrame]
) -> Dict[str, DataFrame]:
    """
    Creates a dataframe and populates indicators for given ticker data
    Used by optimize operations only, not during dry / live runs.
    """
    return {
        pair: self.advise_indicators(pair_data, {"pair": pair})
        for pair, pair_data in tickerdata.items()
    }
# Buggy code
def stoploss_space() -> List[Dimension]:
    """
    Stoploss Value to search

    Override it if you need some different range for the parameter in the
    'stoploss' optimization hyperspace.
    """
    return [
        Real(-0.5, -0.02, name="stoploss"),
    ]


# 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 stoploss_space() -> List[Dimension]:
    """
    Stoploss Value to search

    Override it if you need some different range for the parameter in the
    'stoploss' optimization hyperspace.
    """
    return [
        Real(-0.35, -0.02, name="stoploss"),
    ]
# Buggy code
def rolling_max(series, window=14, min_periods=None):
    min_periods = window if min_periods is None else min_periods
    try:
        return series.rolling(window=window, min_periods=min_periods).min()
    except Exception as e:  # noqa: F841
        return pd.Series(series).rolling(window=window, min_periods=min_periods).min()


# 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 rolling_max(series, window=14, min_periods=None):
    min_periods = window if min_periods is None else min_periods
    try:
        return series.rolling(window=window, min_periods=min_periods).max()
    except Exception as e:  # noqa: F841
        return pd.Series(series).rolling(window=window, min_periods=min_periods).max()
# Buggy code
def get_free(self, currency) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.free:
        return balance.free
    else:
        return 0


# 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 get_free(self, currency: str) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.free:
        return balance.free
    else:
        return 0
# Buggy code
def get_used(self, currency) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.used:
        return balance.used
    else:
        return 0


# 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 get_used(self, currency: str) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.used:
        return balance.used
    else:
        return 0
# Buggy code
def get_total(self, currency) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.total:
        return balance.total
    else:
        return 0


# 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 get_total(self, currency: str) -> float:
    balance = self._wallets.get(currency)
    if balance and balance.total:
        return balance.total
    else:
        return 0
# Buggy code
def __init__(self, args: Dict[str, Any], config=None) -> None:
    """
    Init all variables and objects the bot needs to work
    """
    logger.info("Starting worker %s", __version__)

    self._args = args
    self._config = config
    self._init(False)

    # Tell systemd that we completed initialization phase
    if self._sd_notify:
        logger.debug("sd_notify: READY=1")
        self._sd_notify.notify("READY=1")


# 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 __init__(self, args: Dict[str, Any], config: Dict[str, Any] = None) -> None:
    """
    Init all variables and objects the bot needs to work
    """
    logger.info(f"Starting worker {__version__}")

    self._args = args
    self._config = config
    self._init(False)

    self.last_throttle_start_time: float = 0
    self._heartbeat_msg: float = 0

    # Tell systemd that we completed initialization phase
    if self._sd_notify:
        logger.debug("sd_notify: READY=1")
        self._sd_notify.notify("READY=1")
# Buggy code
def _init(self, reconfig: bool) -> None:
    """
    Also called from the _reconfigure() method (with reconfig=True).
    """
    if reconfig or self._config is None:
        # Load configuration
        self._config = Configuration(self._args, None).get_config()

    # Init the instance of the bot
    self.freqtrade = FreqtradeBot(self._config)

    self._throttle_secs = self._config.get("internals", {}).get(
        "process_throttle_secs", constants.PROCESS_THROTTLE_SECS
    )

    self._sd_notify = (
        sdnotify.SystemdNotifier()
        if self._config.get("internals", {}).get("sd_notify", False)
        else None
    )


# 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 _init(self, reconfig: bool) -> None:
    """
    Also called from the _reconfigure() method (with reconfig=True).
    """
    if reconfig or self._config is None:
        # Load configuration
        self._config = Configuration(self._args, None).get_config()

    # Init the instance of the bot
    self.freqtrade = FreqtradeBot(self._config)

    internals_config = self._config.get("internals", {})
    self._throttle_secs = internals_config.get(
        "process_throttle_secs", constants.PROCESS_THROTTLE_SECS
    )
    self._heartbeat_interval = internals_config.get("heartbeat_interval", 60)

    self._sd_notify = (
        sdnotify.SystemdNotifier()
        if self._config.get("internals", {}).get("sd_notify", False)
        else None
    )
# Buggy code
def _throttle(self, func: Callable[..., Any], min_secs: float, *args, **kwargs) -> Any:
    """
    Throttles the given callable that it
    takes at least `min_secs` to finish execution.
    :param func: Any callable
    :param min_secs: minimum execution time in seconds
    :return: Any
    """
    start = time.time()
    result = func(*args, **kwargs)
    end = time.time()
    duration = max(min_secs - (end - start), 0.0)
    logger.debug("Throttling %s for %.2f seconds", func.__name__, duration)
    time.sleep(duration)
    return result


# 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 _throttle(
    self, func: Callable[..., Any], throttle_secs: float, *args, **kwargs
) -> Any:
    """
    Throttles the given callable that it
    takes at least `min_secs` to finish execution.
    :param func: Any callable
    :param throttle_secs: throttling interation execution time limit in seconds
    :return: Any (result of execution of func)
    """
    self.last_throttle_start_time = time.time()
    logger.debug("========================================")
    result = func(*args, **kwargs)
    time_passed = time.time() - self.last_throttle_start_time
    sleep_duration = max(throttle_secs - time_passed, 0.0)
    logger.debug(
        f"Throttling with '{func.__name__}()': sleep for {sleep_duration:.2f} s, "
        f"last iteration took {time_passed:.2f} s."
    )
    time.sleep(sleep_duration)
    return result
# Buggy code
def get_fee(
    self, symbol="ETH/BTC", type="", side="", amount=1, price=1, taker_or_maker="maker"
) -> float:
    try:
        # validate that markets are loaded before trying to get fee
        if self._api.markets is None or len(self._api.markets) == 0:
            self._api.load_markets()

        return self._api.calculate_fee(
            symbol=symbol,
            type=type,
            side=side,
            amount=amount,
            price=price,
            takerOrMaker=taker_or_maker,
        )["rate"]
    except (ccxt.NetworkError, ccxt.ExchangeError) as e:
        raise TemporaryError(
            f"Could not get fee info due to {e.__class__.__name__}. Message: {e}"
        ) from e
    except ccxt.BaseError as e:
        raise OperationalException(e) from e


# Traceback (KeyError)
2019-12-13 17:08:48,545 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/home/dante/freqtrade/freqtrade/main.py", line 36, in main
return_code = args['func'](args)
File "/home/dante/freqtrade/freqtrade/optimize/__init__.py", line 43, in start_backtesting
backtesting = Backtesting(config)
File "/home/dante/freqtrade/freqtrade/optimize/backtesting.py", line 68, in __init__
self.fee = self.exchange.get_fee()
File "/home/dante/freqtrade/freqtrade/exchange/common.py", line 113, in wrapper
return f(*args, **kwargs)
File "/home/dante/freqtrade/freqtrade/exchange/exchange.py", line 932, in get_fee
price=price, takerOrMaker=taker_or_maker)['rate']
File "/home/dante/.local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1710, in calculate_fee
market = self.markets[symbol]
KeyError: 'ETH/BTC'

# Fixed code
def get_fee(
    self, symbol, type="", side="", amount=1, price=1, taker_or_maker="maker"
) -> float:
    try:
        # validate that markets are loaded before trying to get fee
        if self._api.markets is None or len(self._api.markets) == 0:
            self._api.load_markets()

        return self._api.calculate_fee(
            symbol=symbol,
            type=type,
            side=side,
            amount=amount,
            price=price,
            takerOrMaker=taker_or_maker,
        )["rate"]
    except (ccxt.NetworkError, ccxt.ExchangeError) as e:
        raise TemporaryError(
            f"Could not get fee info due to {e.__class__.__name__}. Message: {e}"
        ) from e
    except ccxt.BaseError as e:
        raise OperationalException(e) from e
# Buggy code
def get_open_trades() -> List[Any]:
    """
    Query trades from persistence layer
    """
    return Trade.query.filter(Trade.is_open.is_(True)).all()


# Traceback (sqlalchemy.exc.InvalidRequestError)
2019-06-30 03:51:36,539 - freqtrade.rpc.telegram - INFO - Executing handler: _forcebuy for chat_id: 146554112
2019-06-30 03:51:36,545 - freqtrade.freqtradebot - INFO - Using Last Ask / Last Price
2019-06-30 03:51:37,260 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': buy, 'exchange': 'Binance', 'pair': 'ALGO/USDT', 'limit': 1.5642505330623224, 'order_type': 'market', 'stake_amount': 13811.040136000001, 'stake_currency': 'USDT', 'fiat_currency': 'USD'}
2019-06-30 03:51:37,612 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=None, pair=ALGO/USDT, amount=8829.17400000, open_rate=1.56425053, open_since=closed)
2019-06-30 03:51:37,758 - freqtrade.freqtradebot - WARNING - Amount 8829.173999999999 does not match amount 8829.174
2019-06-30 03:51:37,760 - freqtrade.freqtradebot - WARNING - Could not update trade amount: Half bought? Amounts don't match
2019-06-30 03:51:37,760 - freqtrade.persistence - INFO - Updating trade (id=None) ...
2019-06-30 03:51:37,760 - freqtrade.persistence - INFO - MARKET_BUY has been fulfilled for Trade(id=None, pair=ALGO/USDT, amount=8829.17400000, open_rate=1.56425053, open_since=closed).
2019-06-30 03:51:37,761 - freqtrade.rpc.telegram - ERROR - Exception occurred within Telegram module
Traceback (most recent call last):
File "/home/dante/freqtrade/freqtrade/rpc/telegram.py", line 52, in wrapper
return command_handler(self, *args, **kwargs)
File "/home/dante/freqtrade/freqtrade/rpc/telegram.py", line 433, in _forcebuy
self._rpc_forcebuy(pair, price)
File "/home/dante/freqtrade/freqtrade/rpc/rpc.py", line 432, in _rpc_forcebuy
if self._freqtrade.execute_buy(pair, stakeamount, price):
File "/home/dante/freqtrade/freqtrade/freqtradebot.py", line 416, in execute_buy
self.update_trade_state(trade, order)
File "/home/dante/freqtrade/freqtrade/freqtradebot.py", line 539, in update_trade_state
trade.update(order)
File "/home/dante/freqtrade/freqtrade/persistence.py", line 317, in update
cleanup()
File "/home/dante/freqtrade/freqtrade/persistence.py", line 155, in cleanup
Trade.session.flush()
File "/home/dante/.local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2445, in flush
raise sa_exc.InvalidRequestError("Session is already flushing")
sqlalchemy.exc.InvalidRequestError: Session is already flushing

# Fixed code
def get_open_trades() -> List[Any]:
    """
    Query trades from persistence layer
    """
    return Trade.get_trades(Trade.is_open.is_(True)).all()
# Buggy code
def convert_amount(
    self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str
) -> float:
    """
    Convert an amount of crypto-currency to fiat
    :param crypto_amount: amount of crypto-currency to convert
    :param crypto_symbol: crypto-currency used
    :param fiat_symbol: fiat to convert to
    :return: float, value in fiat of the crypto-currency amount
    """
    if crypto_symbol == fiat_symbol:
        return crypto_amount
    price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)
    return float(crypto_amount) * float(price)


# Traceback (ValueError)
Traceback (most recent call last):
File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 49, in wrapper
return command_handler(self, *args, **kwargs)
File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 247, in _daily
fiat_disp_cur
File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in _rpc_daily_profit
for key, value in profit_days.items()
File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in <listcomp>
for key, value in profit_days.items()
ValueError: Unknown format code 'f' for object of type 'str'

# Fixed code
def convert_amount(
    self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str
) -> float:
    """
    Convert an amount of crypto-currency to fiat
    :param crypto_amount: amount of crypto-currency to convert
    :param crypto_symbol: crypto-currency used
    :param fiat_symbol: fiat to convert to
    :return: float, value in fiat of the crypto-currency amount
    """
    if crypto_symbol == fiat_symbol:
        return float(crypto_amount)
    price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)
    return float(crypto_amount) * float(price)
# Buggy code
def validate_timeframes(self, timeframe: List[str]) -> None:
    """
    Checks if ticker interval from config is a supported timeframe on the exchange
    """
    timeframes = self._api.timeframes
    if timeframe not in timeframes:
        raise OperationalException(
            f"Invalid ticker {timeframe}, this Exchange supports {timeframes}"
        )


# Traceback (AttributeError)
Traceback (most recent call last):
File "/opt/Projects/freqtrade/freqtrade/main.py", line 51, in main
worker = Worker(args)
File "/opt/Projects/freqtrade/freqtrade/worker.py", line 35, in __init__
self._init(False)
File "/opt/Projects/freqtrade/freqtrade/worker.py", line 51, in _init
self.freqtrade = FreqtradeBot(self._config)
File "/opt/Projects/freqtrade/freqtrade/freqtradebot.py", line 56, in __init__
self.exchange = ExchangeResolver(self.config['exchange']['name'], self.config).exchange
File "/opt/Projects/freqtrade/freqtrade/resolvers/exchange_resolver.py", line 31, in __init__
self.exchange = Exchange(config)
File "/opt/Projects/freqtrade/freqtrade/exchange/exchange.py", line 140, in __init__
self.validate_timeframes(config['ticker_interval'])
File "/opt/Projects/freqtrade/freqtrade/exchange/exchange.py", line 272, in validate_timeframes
timeframes = self._api.timeframes
AttributeError: 'bitstamp' object has no attribute 'timeframes'

# Fixed code
def validate_timeframes(self, timeframe: List[str]) -> None:
    """
    Checks if ticker interval from config is a supported timeframe on the exchange
    """
    if not hasattr(self._api, "timeframes"):
        # If timeframes is missing, the exchange probably has no fetchOHLCV method.
        # Therefore we also show that.
        raise OperationalException(
            f"This exchange ({self.name}) does not have a `timeframes` attribute and "
            f"is therefore not supported. fetchOHLCV: {self.exchange_has('fetchOHLCV')}"
        )
    timeframes = self._api.timeframes
    if timeframe not in timeframes:
        raise OperationalException(
            f"Invalid ticker {timeframe}, this Exchange supports {timeframes}"
        )