def total_exchange_balances(services=None, verbose=None, timeout=None, by_service=False):
balances = defaultdict(lambda: <NUM_LIT:0>)<EOL>if not services:<EOL><INDENT>services = [<EOL>x(verbose=verbose, timeout=timeout)<EOL>for x in ExchangeUniverse.get_authenticated_services()<EOL>]<EOL><DEDENT>for e in services:<EOL><INDENT>try:<EOL><INDENT>more_balances = e.get_total_exchange_balances()<EOL>if by_service:<EOL><INDENT>balances[e.__class__] = more_balances<EOL><DEDENT>else:<EOL><INDENT>for code, bal in more_balances.items():<EOL><INDENT>balances[code] += bal<EOL><DEDENT><DEDENT><DEDENT>except NotImplementedError:<EOL><INDENT>if verbose:<EOL><INDENT>print(e.name, "<STR_LIT>")<EOL><DEDENT><DEDENT>except Exception as exc:<EOL><INDENT>if verbose:<EOL><INDENT>print(e.name, "<STR_LIT>", exc.__class__.__name__, str(exc))<EOL><DEDENT><DEDENT><DEDENT>return balances<EOL>
Returns all balances for all currencies for all exchanges