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

Method fetch_order_book

python/ccxt/async_support/hyperliquid.py:1154–1200  ·  view source on GitHub ↗

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot :param str symbol: unified symbol of the market to fetch the order book for

(self, symbol: str, limit: Int = None, params={})

Source from the content-addressed store, hash-verified

1152 return self.safe_balance(result)
1153
1154 async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
1155 """
1156 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1157
1158 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot
1159
1160 :param str symbol: unified symbol of the market to fetch the order book for
1161 :param int [limit]: the maximum amount of order book entries to return
1162 :param dict [params]: extra parameters specific to the exchange API endpoint
1163 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>`
1164 """
1165 await self.load_markets()
1166 market = self.market(symbol)
1167 request = {
1168 'type': 'l2Book',
1169 'coin': market['baseName'] if market['swap'] else market['id'],
1170 }
1171 response = await self.publicPostInfo(self.extend(request, params))
1172 #
1173 # {
1174 # "coin": "ETH",
1175 # "levels": [
1176 # [
1177 # {
1178 # "n": "2",
1179 # "px": "2216.2",
1180 # "sz": "74.0637"
1181 # }
1182 # ],
1183 # [
1184 # {
1185 # "n": "2",
1186 # "px": "2216.5",
1187 # "sz": "70.5893"
1188 # }
1189 # ]
1190 # ],
1191 # "time": "1704290104840"
1192 # }
1193 #
1194 data = self.safe_list(response, 'levels', [])
1195 result = {
1196 'bids': self.safe_list(data, 0, []),
1197 'asks': self.safe_list(data, 1, []),
1198 }
1199 timestamp = self.safe_integer(response, 'time')
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 """

Callers

nothing calls this directly

Calls 7

marketMethod · 0.95
safe_listMethod · 0.80
safe_integerMethod · 0.80
publicPostInfoMethod · 0.65
load_marketsMethod · 0.45
extendMethod · 0.45
parse_order_bookMethod · 0.45

Tested by

no test coverage detected