Binance API /api/v3/ticker/24hr接口返回字段解析及显示差异技术咨询
Clarifying Binance API v3 24hr Ticker Field Questions
Hey there, let's walk through each of your questions about the Binance 24hr ticker API endpoint— I’ve used this endpoint extensively for trading bots and data analysis, so I can break down the details clearly for you.
1. What do openPrice and prevClosePrice mean, and why do they change on each call?
openPrice: This is the asset’s price at the start of the rolling 24-hour window the API calculates data for. Unlike a fixed calendar day (e.g., UTC 00:00 to 23:59), this window shifts every second—it always represents the 24 hours leading up to the exact moment you make the API call. As time passes, the window’s starting point moves forward, soopenPriceupdates to match the asset’s price at that new starting time.prevClosePrice: This refers to the closing price of the previous 24-hour snapshot window. In most cases, this matchesopenPricebecause the end of the previous window is the start of the current one. But as the rolling window shifts, both values update to reflect the new window’s start and the prior window’s end—hence why they change with each API call.
2. How are priceChange and priceChangePercent calculated?
Your own calculation is spot-on—here’s the exact logic Binance uses:
priceChange: The difference between the currentlastPrice(most recent trade price) and theopenPriceof the current rolling 24-hour window.
Formula:lastPrice - openPrice
In your example:47454.77 - 45935.14 = 1519.63, which matches the returned value.priceChangePercent: The percentage difference betweenlastPriceandopenPrice, relative toopenPrice, multiplied by 100 and rounded to three decimal places.
Formula:((lastPrice - openPrice) / openPrice) * 100
Your manual calculation of 3.308 aligns perfectly with the API’s return, confirming this logic.
3. Why does the API’s 24-hour data differ from Binance’s website display?
The most common reason for this discrepancy is a difference in time window definitions:
- The API returns data for a rolling 24-hour period (from the current time backward 24 hours).
- Binance’s website often displays 24-hour data based on a fixed UTC calendar day (e.g., from UTC 00:00 to the current time) or a custom "trading day" (like UTC 08:00 to the next day’s UTC 08:00, depending on region). These fixed windows don’t shift every second like the API’s rolling window, so their opening prices, volume totals, and high/low values naturally differ.
- Minor gaps can also come from caching: the website’s frontend might cache data for a few seconds to reduce load, while the API returns real-time snapshots of the latest data.
内容的提问来源于stack exchange,提问作者Ross Kelly




