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

Method fetch_order_book

python/ccxt/bybit.py:3273–3335  ·  view source on GitHub ↗

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://bybit-exchange.github.io/docs/v5/market/orderbook :param str symbol: unified symbol of the market to fetch the order book for :param int [limit]: the maximum amoun

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

Source from the content-addressed store, hash-verified

3271 return self.parse_trades(trades, market, since, limit)
3272
3273 def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
3274 """
3275 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
3276
3277 https://bybit-exchange.github.io/docs/v5/market/orderbook
3278
3279 :param str symbol: unified symbol of the market to fetch the order book for
3280 :param int [limit]: the maximum amount of order book entries to return
3281 :param dict [params]: extra parameters specific to the exchange API endpoint
3282 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>`
3283 """
3284 if symbol is None:
3285 raise ArgumentsRequired(self.id + ' fetchOrderBook() requires a symbol argument')
3286 self.load_markets()
3287 market = self.market(symbol)
3288 request = {
3289 'symbol': market['id'],
3290 }
3291 defaultLimit = 25
3292 if market['spot']:
3293 # limit: [1, 50]. Default: 1
3294 defaultLimit = 50
3295 request['category'] = 'spot'
3296 else:
3297 if market['option']:
3298 # limit: [1, 25]. Default: 1
3299 request['category'] = 'option'
3300 elif market['linear']:
3301 # limit: [1, 500]. Default: 25
3302 request['category'] = 'linear'
3303 elif market['inverse']:
3304 # limit: [1, 500]. Default: 25
3305 request['category'] = 'inverse'
3306 request['limit'] = limit if (limit is not None) else defaultLimit
3307 response = self.publicGetV5MarketOrderbook(self.extend(request, params))
3308 #
3309 # {
3310 # "retCode": 0,
3311 # "retMsg": "OK",
3312 # "result": {
3313 # "s": "BTCUSDT",
3314 # "a": [
3315 # [
3316 # "16638.64",
3317 # "0.008479"
3318 # ]
3319 # ],
3320 # "b": [
3321 # [
3322 # "16638.27",
3323 # "0.305749"
3324 # ]
3325 # ],
3326 # "ts": 1672765737733,
3327 # "u": 5277055
3328 # },
3329 # "retExtInfo": {},
3330 # "time": 1672765737734

Callers

nothing calls this directly

Calls 8

ArgumentsRequiredClass · 0.90
safe_dictMethod · 0.80
safe_integerMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45
parse_order_bookMethod · 0.45

Tested by

no test coverage detected