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

Method fetch_tickers

python/ccxt/extended.py:750–797  ·  view source on GitHub ↗

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for all markets https://api.docs.extended.exchange/#get-markets :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are retu

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

Source from the content-addressed store, hash-verified

748 return self.parse_ticker(data, market)
749
750 def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
751 """
752 fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for all markets
753
754 https://api.docs.extended.exchange/#get-markets
755
756 :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
757 :param dict [params]: extra parameters specific to the exchange API endpoint
758 :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
759 """
760 self.load_markets()
761 symbols = self.market_symbols(symbols)
762 request = {}
763 if symbols is not None:
764 marketIds = []
765 for i in range(0, len(symbols)):
766 market = self.market(symbols[i])
767 marketIds.append(market['id'])
768 request['market'] = marketIds
769 response = self.v1PublicGetInfoMarkets(self.extend(request, params))
770 #
771 # {
772 # "status": "OK",
773 # "data": [
774 # {
775 # "name": "BTC-USD",
776 # "assetName": "BTC",
777 # "collateralAssetName": "USD",
778 # "marketStats": {
779 # "dailyVolume": "231016077.512960",
780 # ...
781 # },
782 # ...
783 # }
784 # ]
785 # }
786 #
787 data = self.safe_list(response, 'data', [])
788 tickers = {}
789 for i in range(0, len(data)):
790 marketData = data[i]
791 marketId = self.safe_string(marketData, 'name')
792 market = self.safe_market(marketId)
793 stats = self.safe_dict(marketData, 'marketStats', {})
794 ticker = self.parse_ticker(stats, market)
795 symbol = ticker['symbol']
796 tickers[symbol] = ticker
797 return self.filter_by_array_tickers(tickers, 'symbol', symbols)
798
799 def parse_ticker(self, ticker, market: Market = None) -> Ticker:
800 #

Callers

nothing calls this directly

Calls 13

load_marketsMethod · 0.95
parse_tickerMethod · 0.95
market_symbolsMethod · 0.80
safe_listMethod · 0.80
safe_stringMethod · 0.80
safe_dictMethod · 0.80
rangeFunction · 0.50
marketMethod · 0.45
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected