# Buggy code
async def _async_get_candle_history(
    self, pair: str, tick_interval: str, since_ms: Optional[int] = None
) -> Tuple[str, List]:
    try:
        # fetch ohlcv asynchronously
        logger.debug("fetching %s since %s ...", pair, since_ms)

        data = await self._api_async.fetch_ohlcv(
            pair, timeframe=tick_interval, since=since_ms
        )

        # Because some exchange sort Tickers ASC and other DESC.
        # Ex: Bittrex returns a list of tickers ASC (oldest first, newest last)
        # when GDAX returns a list of tickers DESC (newest first, oldest last)
        # Only sort if necessary to save computing time
        if data and data[0][0] > data[-1][0]:
            data = sorted(data, key=lambda x: x[0])

        logger.debug("done fetching %s ...", pair)
        return pair, data

    except ccxt.NotSupported as e:
        raise OperationalException(
            f"Exchange {self._api.name} does not support fetching historical candlestick data."
            f"Message: {e}"
        )
    except (ccxt.NetworkError, ccxt.ExchangeError) as e:
        raise TemporaryError(
            f"Could not load ticker history due to {e.__class__.__name__}. Message: {e}"
        )
    except ccxt.BaseError as e:
        raise OperationalException(f"Could not fetch ticker data. Msg: {e}")


# Traceback (TypeError)
2019-01-15 18:05:13,808 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
File "/freqtrade/freqtrade/main.py", line 49, in main
state = freqtrade.worker(old_state=state)
File "/freqtrade/freqtrade/freqtradebot.py", line 122, in worker
min_secs=min_secs)
File "/freqtrade/freqtrade/freqtradebot.py", line 134, in _throttle
result = func(*args, **kwargs)
File "/freqtrade/freqtrade/freqtradebot.py", line 170, in _process
self.exchange.refresh_tickers(self.active_pair_whitelist, self.strategy.ticker_interval)
File "/freqtrade/freqtrade/exchange/__init__.py", line 536, in refresh_tickers
self.async_get_candles_history(pair_list, ticker_interval))
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/freqtrade/freqtrade/exchange/__init__.py", line 556, in async_get_candles_history
for pair, ticks in tickers:
TypeError: cannot unpack non-iterable IndexError object
2019-01-15 18:05:13,809 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': status, 'status': 'process died'}

# Fixed code
async def _async_get_candle_history(
    self, pair: str, tick_interval: str, since_ms: Optional[int] = None
) -> Tuple[str, List]:
    try:
        # fetch ohlcv asynchronously
        logger.debug("fetching %s since %s ...", pair, since_ms)

        data = await self._api_async.fetch_ohlcv(
            pair, timeframe=tick_interval, since=since_ms
        )

        # Because some exchange sort Tickers ASC and other DESC.
        # Ex: Bittrex returns a list of tickers ASC (oldest first, newest last)
        # when GDAX returns a list of tickers DESC (newest first, oldest last)
        # Only sort if necessary to save computing time
        try:
            if data and data[0][0] > data[-1][0]:
                data = sorted(data, key=lambda x: x[0])
        except IndexError:
            logger.exception("Error loading %s. Result was %s.", pair, data)
            return pair, []
        logger.debug("done fetching %s ...", pair)
        return pair, data

    except ccxt.NotSupported as e:
        raise OperationalException(
            f"Exchange {self._api.name} does not support fetching historical candlestick data."
            f"Message: {e}"
        )
    except (ccxt.NetworkError, ccxt.ExchangeError) as e:
        raise TemporaryError(
            f"Could not load ticker history due to {e.__class__.__name__}. Message: {e}"
        )
    except ccxt.BaseError as e:
        raise OperationalException(f"Could not fetch ticker data. Msg: {e}")