# Buggy code
def main():
    """
    Loads and validates the config and handles the main loop
    :return: None
    """
    global _CONF
    args = build_arg_parser().parse_args()

    # Initialize logger
    logging.basicConfig(
        level=args.loglevel,
        format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    )

    logger.info(
        "Starting freqtrade %s (loglevel=%s)",
        __version__,
        logging.getLevelName(args.loglevel),
    )

    # Load and validate configuration
    with open(args.config) as file:
        _CONF = json.load(file)
    if "internals" not in _CONF:
        _CONF["internals"] = {}
    logger.info("Validating configuration ...")
    validate(_CONF, CONF_SCHEMA)

    # Initialize all modules and start main loop
    if args.dynamic_whitelist:
        logger.info(
            "Using dynamically generated whitelist. (--dynamic-whitelist detected)"
        )
    init(_CONF)
    old_state = None
    while True:
        new_state = get_state()
        # Log state transition
        if new_state != old_state:
            telegram.send_msg("*Status:* `{}`".format(new_state.name.lower()))
            logger.info("Changing state to: %s", new_state.name)

        if new_state == State.STOPPED:
            time.sleep(1)
        elif new_state == State.RUNNING:
            if args.dynamic_whitelist:
                _CONF["exchange"]["pair_whitelist"] = gen_pair_whitelist(
                    _CONF["stake_currency"]
                )
            throttle(
                _process, min_secs=_CONF["internals"].get("process_throttle_secs", 10)
            )
        old_state = new_state


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/bin/freqtrade", line 4, in <module>
main()
File "/usr/lib/python3.6/site-packages/freqtrade/main.py", line 269, in main
app(_CONF)
File "/usr/lib/python3.6/site-packages/freqtrade/main.py", line 249, in app
_process()
File "/usr/lib/python3.6/site-packages/freqtrade/main.py", line 57, in _process
handle_trade(trade)
File "/usr/lib/python3.6/site-packages/freqtrade/main.py", line 137, in handle_trade
current_rate = exchange.get_ticker(trade.pair)['bid']
File "/usr/lib/python3.6/site-packages/freqtrade/exchange.py", line 118, in get_ticker
'bid': float(data['result']['Bid']),
TypeError: float() argument must be a string or a number, not 'NoneType'
2017-10-07 03:55:46,165 - telegram.ext.updater - ERROR - Error while getting Updates: Timed out

# Fixed code
def main():
    """
    Loads and validates the config and handles the main loop
    :return: None
    """
    global _CONF
    args = build_arg_parser().parse_args()

    # Initialize logger
    logging.basicConfig(
        level=args.loglevel,
        format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    )

    logger.info(
        "Starting freqtrade %s (loglevel=%s)",
        __version__,
        logging.getLevelName(args.loglevel),
    )

    # Load and validate configuration
    with open(args.config) as file:
        _CONF = json.load(file)
    if "internals" not in _CONF:
        _CONF["internals"] = {}
    logger.info("Validating configuration ...")
    validate(_CONF, CONF_SCHEMA)

    # Initialize all modules and start main loop
    if args.dynamic_whitelist:
        logger.info(
            "Using dynamically generated whitelist. (--dynamic-whitelist detected)"
        )
    init(_CONF)
    old_state = None
    while True:
        new_state = get_state()
        # Log state transition
        if new_state != old_state:
            telegram.send_msg("*Status:* `{}`".format(new_state.name.lower()))
            logger.info("Changing state to: %s", new_state.name)

        if new_state == State.STOPPED:
            time.sleep(1)
        elif new_state == State.RUNNING:
            throttle(
                _process,
                min_secs=_CONF["internals"].get("process_throttle_secs", 10),
                dynamic_whitelist=args.dynamic_whitelist,
            )
        old_state = new_state