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

Method fetch_tickers

python/ccxt/async_support/hyperliquid.py:1202–1247  ·  view source on GitHub ↗

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-o

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

Source from the content-addressed store, hash-verified

1200 return self.parse_order_book(result, market['symbol'], timestamp, 'bids', 'asks', 'px', 'sz')
1201
1202 async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1203 """
1204 fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1205
1206 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
1207 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
1208
1209 :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1210 :param dict [params]: extra parameters specific to the exchange API endpoint
1211 :param str [params.type]: 'spot' or 'swap', by default fetches both
1212 :param boolean [params.hip3]: set to True to fetch hip3 markets only
1213 :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
1214 """
1215 await self.load_markets()
1216 symbols = self.market_symbols(symbols)
1217 # at self stage, to get tickers data, we use fetchMarkets endpoints
1218 response = []
1219 type = self.safe_string(params, 'type')
1220 params = self.omit(params, 'type')
1221 hip3 = False
1222 hip3, params = self.handle_option_and_params(params, 'fetchTickers', 'hip3', False)
1223 if symbols is not None:
1224 # infer from first symbol
1225 firstSymbol = self.safe_string(symbols, 0)
1226 if firstSymbol is not None:
1227 market = self.market(firstSymbol)
1228 if self.safe_bool(self.safe_dict(market, 'info'), 'hip3'):
1229 hip3 = True
1230 if hip3:
1231 params = self.omit(params, 'hip3')
1232 response = await self.fetch_hip3_markets(params)
1233 elif type == 'spot':
1234 response = await self.fetch_spot_markets(params)
1235 elif type == 'swap':
1236 response = await self.fetch_swap_markets(params)
1237 else:
1238 response = await self.fetch_markets(params)
1239 # same response "fetchMarkets"
1240 result = {}
1241 for i in range(0, len(response)):
1242 market = response[i]
1243 info = market['info']
1244 ticker = self.parse_ticker(info, market)
1245 symbol = self.safe_string(ticker, 'symbol')
1246 result[symbol] = ticker
1247 return self.filter_by_array_tickers(result, 'symbol', symbols)
1248
1249 async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1250 """

Callers

nothing calls this directly

Calls 15

marketMethod · 0.95
fetch_hip3_marketsMethod · 0.95
fetch_spot_marketsMethod · 0.95
fetch_swap_marketsMethod · 0.95
fetch_marketsMethod · 0.95
parse_tickerMethod · 0.95
market_symbolsMethod · 0.80
safe_stringMethod · 0.80
safe_boolMethod · 0.80
safe_dictMethod · 0.80

Tested by

no test coverage detected