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={})
| 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, |
no test coverage detected