def get_current_price(crypto, fiat, services=None, convert_to=None, helper_prices=None, **modes):
fiat = fiat.lower()<EOL>args = {'<STR_LIT>': crypto, '<STR_LIT>': fiat, '<STR_LIT>': convert_to}<EOL>if not services:<EOL><INDENT>services = get_optimal_services(crypto, '<STR_LIT>')<EOL><DEDENT>if fiat in services:<EOL><INDENT>try_services = services[fiat]<EOL>result = _try_price_fetch(try_services, args, modes)<EOL>if not isinstance(result, Exception):<EOL><INDENT>return result<EOL><DEDENT><DEDENT>if '<STR_LIT:*>' in services:<EOL><INDENT>try_services = services['<STR_LIT:*>']<EOL>result = _try_price_fetch(try_services, args, modes)<EOL>if not isinstance(result, Exception):<EOL><INDENT>return result<EOL><DEDENT><DEDENT>def _do_composite_price_fetch(crypto, convert_crypto, fiat, helpers, modes):<EOL><INDENT>before = modes.get('<STR_LIT>', False)<EOL>modes['<STR_LIT>'] = True<EOL>services1, converted_price = get_current_price(crypto, convert_crypto, **modes)<EOL>if not helpers or convert_crypto not in helpers[fiat]:<EOL><INDENT>services2, fiat_price = get_current_price(convert_crypto, fiat, **modes)<EOL><DEDENT>else:<EOL><INDENT>services2, fiat_price = helpers[fiat][convert_crypto]<EOL><DEDENT>modes['<STR_LIT>'] = before<EOL>if modes.get('<STR_LIT>', False):<EOL><INDENT>serv = CompositeService(services1, services2, convert_crypto)<EOL>return [serv], converted_price * fiat_price<EOL><DEDENT>else:<EOL><INDENT>return converted_price * fiat_price<EOL><DEDENT><DEDENT>all_composite_cryptos = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if crypto in all_composite_cryptos: all_composite_cryptos.remove(crypto)<EOL>for composite_attempt in all_composite_cryptos:<EOL><INDENT>if composite_attempt in services and services[composite_attempt]:<EOL><INDENT>result = _do_composite_price_fetch(<EOL>crypto, composite_attempt, fiat, helper_prices, modes<EOL>)<EOL>if not isinstance(result, Exception):<EOL><INDENT>return result<EOL><DEDENT><DEDENT><DEDENT>raise result<EOL>
High level function for getting current exchange rate for a cryptocurrency.
If the fiat value is not explicitly defined, it will try the wildcard service.
if that does not work, it tries converting to an intermediate cryptocurrency
if available.