# Buggy code
def _balance(bot: Bot, update: Update) -> None:
    """
    Handler for /balance
    Returns current account balance per crypto
    """
    output = ""
    balances = exchange.get_balances()
    for currency in balances:
        if (
            not currency["Balance"]
            and not currency["Available"]
            and not currency["Pending"]
        ):
            continue
        output += """*Currency*: {Currency}
*Available*: {Available}
*Balance*: {Balance}
*Pending*: {Pending}

""".format(**currency)

    send_msg(output)


# Traceback (telegram.error.BadRequest)
2017-11-15 12:08:12,043 - freqtrade.rpc.telegram - INFO - Executing handler: _balance for chat_id: 497298357
2017-11-15 12:08:12,144 - freqtrade.rpc.telegram - WARNING - Got Telegram NetworkError: Message text is empty! Trying one more time.
2017-11-15 12:08:12,288 - freqtrade.rpc.telegram - ERROR - Exception occurred within Telegram module
Traceback (most recent call last):
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/rpc/telegram.py", line 476, in send_msg
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/bot.py", line 57, in decorator
result = func(self, *args, **kwargs)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/bot.py", line 82, in decorator
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/utils/request.py", line 272, in post
**urlopen_kwargs)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/utils/request.py", line 210, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Message text is empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/rpc/telegram.py", line 104, in wrapper
return command_handler(*args, **kwargs)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/rpc/telegram.py", line 288, in _balance
send_msg(output)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/freqtrade/rpc/telegram.py", line 484, in send_msg
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/bot.py", line 57, in decorator
result = func(self, *args, **kwargs)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/bot.py", line 82, in decorator
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/utils/request.py", line 272, in post
**urlopen_kwargs)
File "/Users/sgrimm/dev/cryptos/bots/freqtrade/.env/lib/python3.6/site-packages/telegram/utils/request.py", line 210, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Message text is empty

# Fixed code
def _balance(bot: Bot, update: Update) -> None:
    """
    Handler for /balance
    Returns current account balance per crypto
    """
    output = ""
    balances = [
        c
        for c in exchange.get_balances()
        if c["Balance"] or c["Available"] or c["Pending"]
    ]
    if not balances:
        output = "`All balances are zero.`"

    for currency in balances:
        output += """*Currency*: {Currency}
*Available*: {Available}
*Balance*: {Balance}
*Pending*: {Pending}

""".format(**currency)
    send_msg(output)