fetches the last price for multiple markets https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker # spot https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker
(self, symbols: Strings = None, params={})
| 4385 | return self.parse_tickers(response, symbols) |
| 4386 | |
| 4387 | def fetch_last_prices(self, symbols: Strings = None, params={}): |
| 4388 | """ |
| 4389 | fetches the last price for multiple markets |
| 4390 | |
| 4391 | https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker # spot |
| 4392 | https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Symbol-Price-Ticker # swap |
| 4393 | https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Price-Ticker # future |
| 4394 | |
| 4395 | :param str[]|None symbols: unified symbols of the markets to fetch the last prices |
| 4396 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4397 | :param str [params.subType]: "linear" or "inverse" |
| 4398 | :returns dict: a dictionary of lastprices structures |
| 4399 | """ |
| 4400 | self.load_markets() |
| 4401 | symbols = self.market_symbols(symbols, None, True, True, True) |
| 4402 | market = self.get_market_from_symbols(symbols) |
| 4403 | type = None |
| 4404 | type, params = self.handle_market_type_and_params('fetchLastPrices', market, params) |
| 4405 | subType = None |
| 4406 | subType, params = self.handle_sub_type_and_params('fetchLastPrices', market, params) |
| 4407 | response = None |
| 4408 | if self.is_linear(type, subType): |
| 4409 | response = self.fapiPublicV2GetTickerPrice(params) |
| 4410 | # |
| 4411 | # [ |
| 4412 | # { |
| 4413 | # "symbol": "LTCBTC", |
| 4414 | # "price": "4.00000200" |
| 4415 | # "time": 1589437530011 |
| 4416 | # }, |
| 4417 | # ... |
| 4418 | # ] |
| 4419 | # |
| 4420 | elif self.is_inverse(type, subType): |
| 4421 | response = self.dapiPublicGetTickerPrice(params) |
| 4422 | # |
| 4423 | # [ |
| 4424 | # { |
| 4425 | # "symbol": "BTCUSD_200626", |
| 4426 | # "ps": "9647.8", |
| 4427 | # "price": "9647.8", |
| 4428 | # "time": 1591257246176 |
| 4429 | # } |
| 4430 | # ] |
| 4431 | # |
| 4432 | elif type == 'spot': |
| 4433 | response = self.publicGetTickerPrice(params) |
| 4434 | # |
| 4435 | # [ |
| 4436 | # { |
| 4437 | # "symbol": "LTCBTC", |
| 4438 | # "price": "4.00000200" |
| 4439 | # }, |
| 4440 | # ... |
| 4441 | # ] |
| 4442 | # |
| 4443 | else: |
| 4444 | raise NotSupported(self.id + ' fetchLastPrices() does not support ' + type + ' markets yet') |
nothing calls this directly
no test coverage detected