def fetch_wallet_balances(wallets, fiat, **modes):
price_fetch = set([x[<NUM_LIT:0>] for x in wallets])<EOL>balances = {}<EOL>prices = {}<EOL>fetch_length = len(wallets) + len(price_fetch)<EOL>helpers = {fiat.lower(): {}}<EOL>if not modes.get('<STR_LIT>', False):<EOL><INDENT>for crypto in price_fetch:<EOL><INDENT>try:<EOL><INDENT>p = get_current_price(<EOL>crypto, fiat, helper_prices=helpers, report_services=True, **modes<EOL>)<EOL>prices[crypto] = {'<STR_LIT>': p}<EOL>if crypto in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>helpers[fiat.lower()][crypto] = p<EOL><DEDENT><DEDENT>except NoService as exc:<EOL><INDENT>prices[crypto] = {'<STR_LIT:error>': str(exc)}<EOL><DEDENT><DEDENT>for crypto, address in wallets:<EOL><INDENT>if address.replace('<STR_LIT:.>', '<STR_LIT>').isdigit():<EOL><INDENT>balances[address] = {'<STR_LIT>': float(address)}<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>balances[address] = {'<STR_LIT>': get_address_balance(crypto, address.strip(), **modes)}<EOL><DEDENT>except NoService as exc:<EOL><INDENT>balances[address] = {'<STR_LIT:error>': str(exc)}<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if modes.get('<STR_LIT>', False):<EOL><INDENT>print("<STR_LIT>", fetch_length, "<STR_LIT>")<EOL><DEDENT>with futures.ThreadPoolExecutor(max_workers=int(fetch_length / <NUM_LIT:2>)) as executor:<EOL><INDENT>future_to_key = dict(<EOL>(executor.submit(<EOL>get_current_price, crypto, fiat, report_services=True, **modes<EOL>), crypto) for crypto in price_fetch<EOL>)<EOL>future_to_key.update(dict(<EOL>(executor.submit(<EOL>get_address_balance, crypto, address.strip(), **modes<EOL>), address) for crypto, address in wallets<EOL>))<EOL>done, not_done = futures.wait(future_to_key, return_when=futures.ALL_COMPLETED)<EOL>if len(not_done) > <NUM_LIT:0>:<EOL><INDENT>print (not_done)<EOL>import debug<EOL>raise Exception("<STR_LIT>") <EOL><DEDENT>for future in done:<EOL><INDENT>key = future_to_key[future]<EOL>if len(key) > <NUM_LIT:5>: <EOL><INDENT>which = balances<EOL><DEDENT>else:<EOL><INDENT>which = prices<EOL><DEDENT>res = future.result()<EOL>which[key] = res<EOL><DEDENT><DEDENT><DEDENT>ret = []<EOL>for crypto, address in wallets:<EOL><INDENT>error = None<EOL>if '<STR_LIT>' in balances[address]:<EOL><INDENT>crypto_value = balances[address]['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>crypto_value = <NUM_LIT:0><EOL>error = balances[address]['<STR_LIT:error>']<EOL><DEDENT>if '<STR_LIT>' in prices[crypto]:<EOL><INDENT>sources, fiat_price = prices[crypto]['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>sources, fiat_price = [], <NUM_LIT:0><EOL>error = prices[crypto]['<STR_LIT:error>']<EOL><DEDENT>ret.append({<EOL>'<STR_LIT>': crypto,<EOL>'<STR_LIT:address>': address,<EOL>'<STR_LIT>': crypto_value,<EOL>'<STR_LIT>': (crypto_value or <NUM_LIT:0>) * (fiat_price or <NUM_LIT:0>),<EOL>'<STR_LIT>': fiat_price,<EOL>'<STR_LIT>': sources[<NUM_LIT:0>].name if sources else "<STR_LIT:None>",<EOL>'<STR_LIT:error>': error<EOL>})<EOL><DEDENT>return ret<EOL>
Wallets must be list of two item lists. First item is crypto, second item
is the address. example:

[
    ['btc', '1PZ3Ps9RvCmUW1s1rHE25FeR8vtKUrhEai'],
    ['ltc', 'Lb78JDGxMcih1gs3AirMeRW6jaG5V9hwFZ']
]