# Buggy code
async def async_get_candles_history(
    self, pairs: List[str], tick_interval: str
) -> List[Tuple[str, List]]:
    """Download ohlcv history for pair-list asyncronously"""
    # Calculating ticker interval in second
    interval_in_sec = constants.TICKER_INTERVAL_MINUTES[tick_interval] * 60
    input_coroutines = []

    # Gather corotines to run
    for pair in pairs:
        if not (
            self._pairs_last_refresh_time.get(pair, 0) + interval_in_sec
            >= arrow.utcnow().timestamp
            and pair in self._klines
        ):
            input_coroutines.append(self._async_get_candle_history(pair, tick_interval))
        else:
            logger.debug("Using cached klines data for %s ...", pair)

    tickers = await asyncio.gather(*input_coroutines, return_exceptions=True)

    # handle caching
    for pair, ticks in tickers:
        # keeping last candle time as last refreshed time of the pair
        if ticks:
            self._pairs_last_refresh_time[pair] = ticks[-1][0] // 1000
        # keeping parsed dataframe in cache
        self._klines[pair] = parse_ticker_dataframe(
            ticks, tick_interval, fill_missing=True
        )
    return tickers


# 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_candles_history(
    self, pairs: List[str], tick_interval: str
) -> List[Tuple[str, List]]:
    """Download ohlcv history for pair-list asyncronously"""
    # Calculating ticker interval in second
    interval_in_sec = constants.TICKER_INTERVAL_MINUTES[tick_interval] * 60
    input_coroutines = []

    # Gather corotines to run
    for pair in pairs:
        if not (
            self._pairs_last_refresh_time.get(pair, 0) + interval_in_sec
            >= arrow.utcnow().timestamp
            and pair in self._klines
        ):
            input_coroutines.append(self._async_get_candle_history(pair, tick_interval))
        else:
            logger.debug("Using cached klines data for %s ...", pair)

    tickers = await asyncio.gather(*input_coroutines, return_exceptions=True)

    # handle caching
    for res in tickers:
        if isinstance(res, Exception):
            logger.warning("Async code raised an exception: %s", res.__class__.__name__)
            continue
        pair = res[0]
        ticks = res[1]
        # keeping last candle time as last refreshed time of the pair
        if ticks:
            self._pairs_last_refresh_time[pair] = ticks[-1][0] // 1000
            # keeping parsed dataframe in cache
            self._klines[pair] = parse_ticker_dataframe(
                ticks, tick_interval, fill_missing=True
            )
    return tickers