[英]Last price from FUTURES market on Binance API with Python
I am using the API endpoint https://api.binance.com/api/v1/ticker/24hr?symbol= to get last price info for markets, but I need the data for the FUTURES market, as sometimes there can be a big spread between the spot and futures last price.我正在使用 API 端点https://api.binance.com/api/v1/ticker/24hr?symbol=获取市场的最新价格信息,但我需要期货市场的数据,因为有时可能会有现货和期货最新价格之间的巨大价差。
How can I get this data point?我怎样才能得到这个数据点?
Using binance-python lib and python 3.使用 binance-python 库和 python 3.
Use this endpoint to get the last price of the Pair in the futures market https://fapi.binance.com/fapi/v1/ticker/24hr?symbol= <SYMBOL_NAME>.使用此端点获取 Pair 在期货市场的最新价格https://fapi.binance.com/fapi/v1/ticker/24hr?symbol= <SYMBOL_NAME>。
Example:例子:
https://fapi.binance.com/fapi/v1/ticker/24hr?symbol=BNBUSDT https://fapi.binance.com/fapi/v1/ticker/24hr?symbol=BNBUSDT
Check this documentation link for more information查看此文档链接以获取更多信息
For people who want to use binance-futures-connector-python to get the latest price of a symbol, you may use the following code.对于想要使用binance-futures-connector-python获取交易品种最新价格的人,您可以使用以下代码。
from binance.um_futures import UMFutures
um_futures_client = UMFutures()
print(um_futures_client.ticker_price("BTCUSDT")) # returns something like {'symbol': 'BTCUSDT', 'price': '22774.80', 'time': 1674457064454}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.