MCPcopy Create free account
hub / github.com/ccxt/ccxt / get_valid_symbol

Method get_valid_symbol

python/ccxt/test/tests_async.py:473–505  ·  view source on GitHub ↗
(self, exchange, spot=True)

Source from the content-addressed store, hash-verified

471 return res
472
473 def get_valid_symbol(self, exchange, spot=True):
474 current_type_markets = self.get_markets_from_exchange(exchange, spot)
475 codes = ['BTC', 'ETH', 'XRP', 'LTC', 'BNB', 'DASH', 'DOGE', 'ETC', 'TRX', 'USDT', 'USDC', 'USD', 'GUSD', 'EUR', 'TUSD', 'CNY', 'JPY', 'BRL']
476 spot_symbols = ['BTC/USDT', 'BTC/USDC', 'BTC/USD', 'BTC/CNY', 'BTC/EUR', 'BTC/AUD', 'BTC/BRL', 'BTC/JPY', 'ETH/USDT', 'ETH/USDC', 'ETH/USD', 'ETH/CNY', 'ETH/EUR', 'ETH/AUD', 'ETH/BRL', 'ETH/JPY', 'EUR/USDT', 'EUR/USD', 'EUR/USDC', 'USDT/EUR', 'USD/EUR', 'USDC/EUR', 'BTC/ETH', 'ETH/BTC']
477 swap_symbols = ['BTC/USDT:USDT', 'BTC/USD:USDT', 'BTC/USDC:USDC', 'BTC/USD:USDC', 'BTC/USD:USD', 'ETH/USDT:USDT', 'ETH/USD:USDT', 'ETH/USDC:USDC', 'ETH/USD:USDC', 'ETH/USD:USD', 'BTC/USD:BTC', 'ETH/USD:ETH']
478 target_symbols = spot_symbols if spot else swap_symbols
479 symbol = self.get_test_symbol(exchange, spot, target_symbols)
480 # if symbols wasn't found from above hardcoded list, then try to locate any symbol which has our target hardcoded 'base' code
481 if symbol is None:
482 for i in range(0, len(codes)):
483 current_code = codes[i]
484 markets_array_for_current_code = exchange.filter_by(current_type_markets, 'base', current_code)
485 indexed_mkts = exchange.index_by(markets_array_for_current_code, 'symbol')
486 symbols_array_for_current_code = list(indexed_mkts.keys())
487 symbols_length = len(symbols_array_for_current_code)
488 if symbols_length:
489 symbol = self.get_test_symbol(exchange, spot, symbols_array_for_current_code)
490 break
491 # if there wasn't found any symbol with our hardcoded 'base' code, then just try to find symbols that are 'active'
492 if symbol is None:
493 active_markets = exchange.filter_by(current_type_markets, 'active', True)
494 active_symbols = []
495 for i in range(0, len(active_markets)):
496 active_symbols.append(active_markets[i]['symbol'])
497 symbol = self.get_test_symbol(exchange, spot, active_symbols)
498 if symbol is None:
499 values = list(current_type_markets.values())
500 values_length = len(values)
501 if values_length > 0:
502 first = values[0]
503 if first:
504 symbol = first['symbol']
505 return symbol
506
507 async def test_exchange(self, exchange, provided_symbol=None):
508 spot_symbols = None

Callers 1

test_exchangeMethod · 0.95

Calls 7

get_test_symbolMethod · 0.95
filter_byMethod · 0.80
index_byMethod · 0.80
rangeFunction · 0.50
appendMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected