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

Method fetch_order_book

python/ccxt/extended.py:862–905  ·  view source on GitHub ↗

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://api.docs.extended.exchange/#get-market-order-book :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

860 }, market)
861
862 def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
863 """
864 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
865
866 https://api.docs.extended.exchange/#get-market-order-book
867
868 :param str symbol: unified symbol of the market to fetch the order book for
869 :param int [limit]: the maximum amount of order book entries to return
870 :param dict [params]: extra parameters specific to the exchange API endpoint
871 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>`
872 """
873 self.load_markets()
874 market = self.market(symbol)
875 request = {
876 'market': market['id'],
877 }
878 response = self.v1PublicGetInfoMarketsMarketOrderbook(self.extend(request, params))
879 #
880 # {
881 # "status": "OK",
882 # "data": {
883 # "market": "BTC-USD",
884 # "bid": [
885 # {
886 # "qty": "14.46084",
887 # "price": "76214"
888 # }
889 # ],
890 # "ask": [
891 # {
892 # "qty": "0.11585",
893 # "price": "76215"
894 # }
895 # ]
896 # }
897 # }
898 #
899 data = self.safe_dict(response, 'data', {})
900 timestamp = self.milliseconds()
901 orderbook = self.parse_order_book(data, market['symbol'], timestamp, 'bid', 'ask', 'price', 'qty')
902 if limit is not None:
903 orderbook['bids'] = self.array_slice(orderbook['bids'], 0, limit)
904 orderbook['asks'] = self.array_slice(orderbook['asks'], 0, limit)
905 return orderbook
906
907 def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
908 """

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected