# Buggy code
def get_ticker_history(self, pair: str, tick_interval: int) -> List[Dict]:
    if tick_interval == 1:
        interval = "oneMin"
    elif tick_interval == 5:
        interval = "fiveMin"
    else:
        raise ValueError("Cannot parse tick_interval: {}".format(tick_interval))

    data = _API_V2.get_candles(pair.replace("_", "-"), interval)

    # These sanity check are necessary because bittrex cannot keep their API stable.
    if not data.get("result"):
        return []

    for prop in ["C", "V", "O", "H", "L", "T"]:
        for tick in data["result"]:
            if prop not in tick.keys():
                logger.warning("Required property %s not present in response", prop)
                return []

    if not data["success"]:
        raise RuntimeError(
            "{message} params=({pair})".format(message=data["message"], pair=pair)
        )

    return data["result"]


# Traceback (TypeError)
2017-11-15 12:14:48,532 - freqtrade - INFO - Checking buy signals to create a new trade with stake_amount: 0.050000 ...
2017-11-15 12:14:58,986 - freqtrade - INFO - *BITTREX:* Buying [BTC/LUN](https://www.bittrex.com/Market/Index?MarketName=BTC-LUN) with limit `0.00065566`
2017-11-15 12:15:00,378 - freqtrade - INFO - Got open order for Trade(id=5, pair=BTC_LUN, amount=76.06838910410885, open_rate=0.00065566, open_since=just now)
Traceback (most recent call last):
File "./freqtrade/main.py", line 361, in <module>
main()
File "./freqtrade/main.py", line 355, in main
dynamic_whitelist=args.dynamic_whitelist,
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/misc.py", line 52, in throttle
result = func(*args, **kwargs)
File "./freqtrade/main.py", line 91, in _process
state_changed = handle_trade(trade) or state_changed
File "./freqtrade/main.py", line 181, in handle_trade
current_rate = exchange.get_ticker(trade.pair)['bid']
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/exchange/__init__.py", line 128, in get_ticker
return _API.get_ticker(pair)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/exchange/bittrex.py", line 85, in get_ticker
if not data['result']['Bid'] or not data['result']['Ask'] or not data['result']['Last']:
TypeError: 'NoneType' object is not subscriptable
2

# Fixed code
def get_ticker_history(self, pair: str, tick_interval: int) -> List[Dict]:
    if tick_interval == 1:
        interval = "oneMin"
    elif tick_interval == 5:
        interval = "fiveMin"
    else:
        raise ValueError("Cannot parse tick_interval: {}".format(tick_interval))

    data = _API_V2.get_candles(pair.replace("_", "-"), interval)

    # These sanity check are necessary because bittrex cannot keep their API stable.
    if not data.get("result"):
        raise ContentDecodingError(
            "{message} params=({pair})".format(
                message="Got invalid response from bittrex", pair=pair
            )
        )

    for prop in ["C", "V", "O", "H", "L", "T"]:
        for tick in data["result"]:
            if prop not in tick.keys():
                raise ContentDecodingError(
                    "{message} params=({pair})".format(
                        message="Required property {} not present in response".format(
                            prop
                        ),
                        pair=pair,
                    )
                )

    if not data["success"]:
        raise RuntimeError(
            "{message} params=({pair})".format(message=data["message"], pair=pair)
        )

    return data["result"]