fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book # spot https://developers.binance.com/docs/derivatives/usds-margined-futur
(self, symbol: str, limit: Int = None, params={})
| 4023 | return self.parse_balance_custom(response, type, marginMode, isPortfolioMargin) |
| 4024 | |
| 4025 | def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook: |
| 4026 | """ |
| 4027 | fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data |
| 4028 | |
| 4029 | https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book # spot |
| 4030 | https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book # swap |
| 4031 | https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Order-Book-RPI # swap rpi |
| 4032 | https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Order-Book # future |
| 4033 | https://developers.binance.com/docs/derivatives/option/market-data/Order-Book # option |
| 4034 | |
| 4035 | :param str symbol: unified symbol of the market to fetch the order book for |
| 4036 | :param int [limit]: the maximum amount of order book entries to return |
| 4037 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4038 | :param boolean [params.rpi]: *future only* set to True to use the RPI endpoint |
| 4039 | :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` |
| 4040 | """ |
| 4041 | self.load_markets() |
| 4042 | market = self.market(symbol) |
| 4043 | request = { |
| 4044 | 'symbol': market['id'], |
| 4045 | } |
| 4046 | if limit is not None: |
| 4047 | request['limit'] = limit # default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book |
| 4048 | response = None |
| 4049 | if market['option']: |
| 4050 | response = self.eapiPublicGetDepth(self.extend(request, params)) |
| 4051 | elif market['linear']: |
| 4052 | rpi = self.safe_value(params, 'rpi', False) |
| 4053 | params = self.omit(params, 'rpi') |
| 4054 | if rpi: |
| 4055 | # rpi limit only supports 1000 |
| 4056 | request['limit'] = 1000 |
| 4057 | response = self.fapiPublicGetRpiDepth(self.extend(request, params)) |
| 4058 | else: |
| 4059 | response = self.fapiPublicGetDepth(self.extend(request, params)) |
| 4060 | elif market['inverse']: |
| 4061 | response = self.dapiPublicGetDepth(self.extend(request, params)) |
| 4062 | else: |
| 4063 | response = self.publicGetDepth(self.extend(request, params)) |
| 4064 | # |
| 4065 | # future |
| 4066 | # |
| 4067 | # { |
| 4068 | # "lastUpdateId":333598053905, |
| 4069 | # "E":1618631511986, |
| 4070 | # "T":1618631511964, |
| 4071 | # "bids":[ |
| 4072 | # ["2493.56","20.189"], |
| 4073 | # ["2493.54","1.000"], |
| 4074 | # ["2493.51","0.005"] |
| 4075 | # ], |
| 4076 | # "asks":[ |
| 4077 | # ["2493.57","0.877"], |
| 4078 | # ["2493.62","0.063"], |
| 4079 | # ["2493.71","12.054"], |
| 4080 | # ] |
| 4081 | # } |
| 4082 | # |
nothing calls this directly
no test coverage detected