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

Method fetch_order_book

python/ccxt/delta.py:1389–1427  ·  view source on GitHub ↗

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://docs.delta.exchange/#get-l2-orderbook :param str symbol: unified symbol of the market to fetch the order book for :param int [limit]: the maximum amount of order b

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

Source from the content-addressed store, hash-verified

1387 return self.filter_by_array_tickers(result, 'symbol', symbols)
1388
1389 def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
1390 """
1391 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1392
1393 https://docs.delta.exchange/#get-l2-orderbook
1394
1395 :param str symbol: unified symbol of the market to fetch the order book for
1396 :param int [limit]: the maximum amount of order book entries to return
1397 :param dict [params]: extra parameters specific to the exchange API endpoint
1398 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>`
1399 """
1400 self.load_markets()
1401 market = self.market(symbol)
1402 request = {
1403 'symbol': market['id'],
1404 }
1405 if limit is not None:
1406 request['depth'] = limit
1407 response = self.publicGetL2orderbookSymbol(self.extend(request, params))
1408 #
1409 # {
1410 # "result":{
1411 # "buy":[
1412 # {"price":"15814.0","size":912},
1413 # {"price":"15813.5","size":1279},
1414 # {"price":"15813.0","size":1634},
1415 # ],
1416 # "sell":[
1417 # {"price":"15814.5","size":625},
1418 # {"price":"15815.0","size":982},
1419 # {"price":"15815.5","size":1328},
1420 # ],
1421 # "symbol":"BTCUSDT"
1422 # },
1423 # "success":true
1424 # }
1425 #
1426 result = self.safe_dict(response, 'result', {})
1427 return self.parse_order_book(result, market['symbol'], None, 'buy', 'sell', 'price', 'size')
1428
1429 def parse_trade(self, trade: dict, market: Market = None) -> Trade:
1430 #

Callers

nothing calls this directly

Calls 6

load_marketsMethod · 0.95
safe_dictMethod · 0.80
marketMethod · 0.45
extendMethod · 0.45
parse_order_bookMethod · 0.45

Tested by

no test coverage detected