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

Method fetch_order_book

python/ccxt/xt.py:1512–1597  ·  view source on GitHub ↗

https://doc.xt.com/#market3depth https://doc.xt.com/#futures_quotesgetDepth fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data :param str symbol: unified market symbol to fetch the order book for :param int [limit]

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

Source from the content-addressed store, hash-verified

1510 ]
1511
1512 def fetch_order_book(self, symbol: str, limit: Int = None, params={}):
1513 """
1514
1515 https://doc.xt.com/#market3depth
1516 https://doc.xt.com/#futures_quotesgetDepth
1517
1518 fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1519 :param str symbol: unified market symbol to fetch the order book for
1520 :param int [limit]: the maximum amount of order book entries to return
1521 :param dict params: extra parameters specific to the xt api endpoint
1522 :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/en/latest/manual.html#order-book-structure>` indexed by market symbols
1523 """
1524 self.load_markets()
1525 market = self.market(symbol)
1526 request = {
1527 'symbol': market['id'],
1528 }
1529 response = None
1530 if market['spot']:
1531 if limit is not None:
1532 request['limit'] = min(limit, 500)
1533 response = self.publicSpotGetDepth(self.extend(request, params))
1534 else:
1535 if limit is not None:
1536 request['level'] = min(limit, 50)
1537 else:
1538 request['level'] = 50
1539 if market['linear']:
1540 response = self.publicLinearGetFutureMarketV1PublicQDepth(self.extend(request, params))
1541 elif market['inverse']:
1542 response = self.publicInverseGetFutureMarketV1PublicQDepth(self.extend(request, params))
1543 #
1544 # spot
1545 #
1546 # {
1547 # "rc": 0,
1548 # "mc": "SUCCESS",
1549 # "ma": [],
1550 # "result": {
1551 # "timestamp": 1678169975184,
1552 # "lastUpdateId": 1675333221812,
1553 # "bids": [
1554 # ["22444.51", "0.129887"],
1555 # ["22444.49", "0.114245"],
1556 # ["22444.30", "0.225956"]
1557 # ],
1558 # "asks": [
1559 # ["22446.19", "0.095330"],
1560 # ["22446.24", "0.224413"],
1561 # ["22446.28", "0.329095"]
1562 # ]
1563 # }
1564 # }
1565 #
1566 # swap and future
1567 #
1568 # {
1569 # "returnCode": 0,

Callers 15

mainFunction · 0.45
sync_clientFunction · 0.45
async_clientFunction · 0.45
loopFunction · 0.45
fetch_orderbookFunction · 0.45
pollFunction · 0.45
memleak-test.pyFile · 0.45
symbol_loopFunction · 0.45
latoken-example.pyFile · 0.45

Calls 10

safe_valueMethod · 0.80
safe_integer_2Method · 0.80
safe_integerMethod · 0.80
publicSpotGetDepthMethod · 0.65
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45
parse_order_bookMethod · 0.45

Tested by

no test coverage detected