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

Method fetch_tickers

python/ccxt/bybit.py:2536–2632  ·  view source on GitHub ↗

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market https://bybit-exchange.github.io/docs/v5/market/tickers :param str[] symbols: unified symbols of the markets to fetch the ticker for, all market tickers ar

(self, symbols: Strings = None, params={})

Source from the content-addressed store, hash-verified

2534 return self.parse_ticker(rawTicker, market)
2535
2536 def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
2537 """
2538 fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
2539
2540 https://bybit-exchange.github.io/docs/v5/market/tickers
2541
2542 :param str[] symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2543 :param dict [params]: extra parameters specific to the exchange API endpoint
2544 :param str [params.subType]: *contract only* 'linear', 'inverse'
2545 :param str [params.baseCoin]: *option only* base coin, default is 'BTC'
2546 :returns dict: an array of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
2547 """
2548 self.load_markets()
2549 code = self.safe_string_n(params, ['code', 'currency', 'baseCoin'])
2550 market = None
2551 parsedSymbols = None
2552 if symbols is not None:
2553 parsedSymbols = []
2554 marketTypeInfo = self.handle_market_type_and_params('fetchTickers', None, params)
2555 defaultType = marketTypeInfo[0] # don't omit here
2556 # we can't use marketSymbols here due to the conflicing ids between markets
2557 currentType = None
2558 for i in range(0, len(symbols)):
2559 symbol = symbols[i]
2560 # using safeMarket here because if the user provides for instance BTCUSDT and "type": "spot" in params we should
2561 # infer the market type from the type provided and not from the conflicting id(BTCUSDT might be swap or spot)
2562 isExchangeSpecificSymbol = (symbol.find('/') == -1)
2563 if isExchangeSpecificSymbol:
2564 market = self.safe_market(symbol, None, None, defaultType)
2565 else:
2566 market = self.market(symbol)
2567 if currentType is None:
2568 currentType = market['type']
2569 elif market['type'] != currentType:
2570 raise BadRequest(self.id + ' fetchTickers can only accept a list of symbols of the same type')
2571 if market['option']:
2572 if code is not None and code != market['base']:
2573 raise BadRequest(self.id + ' fetchTickers the base currency must be the same for all symbols, self endpoint only supports one base currency at a time. Read more about it here: https://bybit-exchange.github.io/docs/v5/market/tickers')
2574 if code is None:
2575 code = market['base']
2576 params = self.omit(params, ['code', 'currency'])
2577 parsedSymbols.append(market['symbol'])
2578 request = {
2579 # 'symbol': market['id'],
2580 # 'baseCoin': '', # Base coin. For option only
2581 # 'expDate': '', # Expiry date. e.g., 25DEC22. For option only
2582 }
2583 category = None
2584 category, params = self.get_bybit_type('fetchTickers', market, params)
2585 request['category'] = category
2586 if category == 'option':
2587 request['category'] = 'option'
2588 if code is None:
2589 code = 'BTC'
2590 request['baseCoin'] = code
2591 response = self.publicGetV5MarketTickers(self.extend(request, params))
2592 #
2593 # {

Callers 1

fetch_bids_asksMethod · 0.95

Calls 15

safe_marketMethod · 0.95
get_bybit_typeMethod · 0.95
BadRequestClass · 0.90
safe_string_nMethod · 0.80
findMethod · 0.80
safe_dictMethod · 0.80
safe_listMethod · 0.80
rangeFunction · 0.50
load_marketsMethod · 0.45
marketMethod · 0.45

Tested by

no test coverage detected