fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://www.gate.com/docs/developers/apiv4/en/#get-market-depth-information https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information https://ww
(self, symbol: str, limit: Int = None, params={})
| 2622 | } |
| 2623 | |
| 2624 | def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook: |
| 2625 | """ |
| 2626 | fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data |
| 2627 | |
| 2628 | https://www.gate.com/docs/developers/apiv4/en/#get-market-depth-information |
| 2629 | https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information |
| 2630 | https://www.gate.com/docs/developers/apiv4/en/#query-futures-market-depth-information-2 |
| 2631 | https://www.gate.com/docs/developers/apiv4/en/#query-options-contract-order-book |
| 2632 | |
| 2633 | :param str symbol: unified symbol of the market to fetch the order book for |
| 2634 | :param int [limit]: the maximum amount of order book entries to return |
| 2635 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2636 | :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` |
| 2637 | """ |
| 2638 | self.load_markets() |
| 2639 | market = self.market(symbol) |
| 2640 | # |
| 2641 | # request = { |
| 2642 | # 'currency_pair': market['id'], |
| 2643 | # 'interval': '0', # depth, 0 means no aggregation is applied, default to 0 |
| 2644 | # 'limit': limit, # maximum number of order depth data in asks or bids |
| 2645 | # 'with_id': True, # return order book ID |
| 2646 | # } |
| 2647 | # |
| 2648 | request, query = self.prepare_request(market, market['type'], params) |
| 2649 | if limit is not None: |
| 2650 | if market['spot']: |
| 2651 | limit = min(limit, 1000) |
| 2652 | else: |
| 2653 | limit = min(limit, 300) |
| 2654 | request['limit'] = limit |
| 2655 | request['with_id'] = True |
| 2656 | response: dict |
| 2657 | if market['spot'] or market['margin']: |
| 2658 | response = self.publicSpotGetOrderBook(self.extend(request, query)) |
| 2659 | elif market['swap']: |
| 2660 | response = self.publicFuturesGetSettleOrderBook(self.extend(request, query)) |
| 2661 | elif market['future']: |
| 2662 | response = self.publicDeliveryGetSettleOrderBook(self.extend(request, query)) |
| 2663 | elif market['option']: |
| 2664 | response = self.publicOptionsGetOrderBook(self.extend(request, query)) |
| 2665 | else: |
| 2666 | raise NotSupported(self.id + ' fetchOrderBook() not support self market type') |
| 2667 | # |
| 2668 | # spot |
| 2669 | # |
| 2670 | # { |
| 2671 | # "id": 6358770031 |
| 2672 | # "current": 1634345973275, |
| 2673 | # "update": 1634345973271, |
| 2674 | # "asks": [ |
| 2675 | # ["2.2241","12449.827"], |
| 2676 | # ["2.2242","200"], |
| 2677 | # ["2.2244","826.931"], |
| 2678 | # ["2.2248","3876.107"], |
| 2679 | # ["2.225","2377.252"], |
| 2680 | # ["2.22509","439.484"], |
| 2681 | # ["2.2251","1489.313"], |
nothing calls this directly
no test coverage detected