# Buggy code
def create_stoploss_order(self, trade: Trade, stop_price: float, rate: float) -> bool:
    """
    Abstracts creating stoploss orders from the logic.
    Handles errors and updates the trade database object.
    Force-sells the pair (using EmergencySell reason) in case of Problems creating the order.
    :return: True if the order succeeded, and False in case of problems.
    """
    # Limit price threshold: As limit price should always be below stop-price
    LIMIT_PRICE_PCT = self.strategy.order_types.get(
        "stoploss_on_exchange_limit_ratio", 0.99
    )

    try:
        stoploss_order = self.exchange.stoploss_limit(
            pair=trade.pair,
            amount=trade.amount,
            stop_price=stop_price,
            rate=rate * LIMIT_PRICE_PCT,
        )
        trade.stoploss_order_id = str(stoploss_order["id"])
        return True
    except InvalidOrderException as e:
        trade.stoploss_order_id = None
        logger.error(f"Unable to place a stoploss order on exchange. {e}")
        logger.warning("Selling the trade forcefully")
        self.execute_sell(trade, trade.stop_loss, sell_reason=SellType.EMERGENCY_SELL)

    except DependencyException:
        trade.stoploss_order_id = None
        logger.exception("Unable to place a stoploss order on exchange.")
    return False


# 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 create_stoploss_order(self, trade: Trade, stop_price: float, rate: float) -> bool:
    """
    Abstracts creating stoploss orders from the logic.
    Handles errors and updates the trade database object.
    Force-sells the pair (using EmergencySell reason) in case of Problems creating the order.
    :return: True if the order succeeded, and False in case of problems.
    """
    try:
        stoploss_order = self.exchange.stoploss(
            pair=trade.pair,
            amount=trade.amount,
            stop_price=stop_price,
            order_types=self.strategy.order_types,
        )
        trade.stoploss_order_id = str(stoploss_order["id"])
        return True
    except InvalidOrderException as e:
        trade.stoploss_order_id = None
        logger.error(f"Unable to place a stoploss order on exchange. {e}")
        logger.warning("Selling the trade forcefully")
        self.execute_sell(trade, trade.stop_loss, sell_reason=SellType.EMERGENCY_SELL)

    except DependencyException:
        trade.stoploss_order_id = None
        logger.exception("Unable to place a stoploss order on exchange.")
    return False