def get_markets_list(base='BTC', exchange='bittrex'): ''' Gets all coins from a certain market. Args: - base: if you want just one market. Ex: BTC. Empty for all markets. Returns: - list of markets. - False if unsupported exchange. ''' ret = False if exchange == 'bittrex': try: bt = Bittrex('', '') log("[INFO] Connected to Bittrex.", 1) ret = [ i['MarketName'] for i in bt.get_markets()['result'] if i['MarketName'].startswith(base) ] except Exception as e: log("[ERROR] Connecting to Bittrex...", 0) elif exchange == 'binance': try: bnb = Binance('', '') log("[INFO] Connected to Binance.", 1) ret = [ i['symbol'] for i in bnb.get_all_tickers() if i['symbol'].endswith(base) ] except Exception as e: log("[ERROR] Connecting to Binance...", 0) return ret
def get_markets_list(base='BTC', exchange='bittrex'): """ Gets all coins from a certain market. Args: - base: if you want just one market. Ex: BTC. Empty for all markets. Returns: - list of markets. - False if unsupported exchange. """ ret = False if exchange == 'bittrex': try: bt = Bittrex('', '') log.debug("Connected to Bittrex.") ret = [ i['MarketName'] for i in bt.get_markets()['result'] if i['MarketName'].startswith(base) ] except Exception as e: log.exception(f"Unable to connect to Bittrex - {e}") elif exchange == 'binance': try: bnb = Binance('', '') log.debug("Connected to Binance.") ret = [ i['symbol'] for i in bnb.get_all_tickers() if i['symbol'].endswith(base) ] except Exception as e: log.exception(f"Unable to connect to Binance - {e}") return ret