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

Method fetch_order_book

python/ccxt/hyperliquid.py:1153–1199  ·  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

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

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