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

Method fetch_order_book

python/ccxt/bitrue.py:1210–1277  ·  view source on GitHub ↗

fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://github.com/Bitrue-exchange/Spot-official-api-docs#order-book https://www.bitrue.com/api-docs#order-book https://www.bitrue.com/api_docs_includes_file/delivery.html#

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

Source from the content-addressed store, hash-verified

1208 return self.parse_balance(result)
1209
1210 def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
1211 """
1212 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1213
1214 https://github.com/Bitrue-exchange/Spot-official-api-docs#order-book
1215 https://www.bitrue.com/api-docs#order-book
1216 https://www.bitrue.com/api_docs_includes_file/delivery.html#order-book
1217
1218 :param str symbol: unified symbol of the market to fetch the order book for
1219 :param int [limit]: the maximum amount of order book entries to return
1220 :param dict [params]: extra parameters specific to the exchange API endpoint
1221 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>`
1222 """
1223 self.load_markets()
1224 market = self.market(symbol)
1225 response = {}
1226 if market['swap']:
1227 request = {
1228 'contractName': market['id'],
1229 }
1230 if limit is not None:
1231 if limit > 100:
1232 limit = 100
1233 request['limit'] = limit # default 100, max 100, see https://www.bitrue.com/api-docs#order-book
1234 if market['linear']:
1235 response = self.fapiV1PublicGetDepth(self.extend(request, params))
1236 elif market['inverse']:
1237 response = self.dapiV1PublicGetDepth(self.extend(request, params))
1238 elif market['spot']:
1239 request = {
1240 'symbol': market['id'],
1241 }
1242 if limit is not None:
1243 if limit > 1000:
1244 limit = 1000
1245 request['limit'] = limit # default 100, max 1000, see https://github.com/Bitrue-exchange/bitrue-official-api-docs#order-book
1246 response = self.spotV1PublicGetDepth(self.extend(request, params))
1247 else:
1248 raise NotSupported(self.id + ' fetchOrderBook only support spot & swap markets')
1249 #
1250 # spot
1251 #
1252 # {
1253 # "lastUpdateId":1635474910177,
1254 # "bids":[
1255 # ["61436.84","0.05",[]],
1256 # ["61435.77","0.0124",[]],
1257 # ["61434.88","0.012",[]],
1258 # ],
1259 # "asks":[
1260 # ["61452.46","0.0001",[]],
1261 # ["61452.47","0.0597",[]],
1262 # ["61452.76","0.0713",[]],
1263 # ]
1264 # }
1265 #
1266 # swap
1267 #

Callers

nothing calls this directly

Calls 10

NotSupportedClass · 0.90
safe_integer_2Method · 0.80
safe_integerMethod · 0.80
fapiV1PublicGetDepthMethod · 0.65
dapiV1PublicGetDepthMethod · 0.65
spotV1PublicGetDepthMethod · 0.65
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45
parse_order_bookMethod · 0.45

Tested by

no test coverage detected