我正在开发自己的应用程序,我想在其中检索 24 小时内的价格数据。我已阅读币安提供的文档:https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md
然后我尝试获取24小时股票价格变动统计通过使用链接https://api.binance.com/api/v1/ticker/24hr?symbol=BTCUSDT https://api.binance.com/api/v1/ticker/24hr?symbol=BTCUSDT。响应是:
{
"symbol": "BTCUSDT",
"priceChange": "111.60000000",
"priceChangePercent": "1.314",
"weightedAvgPrice": "8563.97044287",
"prevClosePrice": "8491.29000000",
"lastPrice": "8604.60000000",
"lastQty": "0.40675900",
"bidPrice": "8602.69000000",
"bidQty": "0.02000000",
"askPrice": "8610.79000000",
"askQty": "0.13200000",
"openPrice": "8493.00000000",
"highPrice": "8763.36000000",
"lowPrice": "8298.00000000",
"volume": "26054.86683400",
"quoteVolume": "223133109.45927182",
"openTime": 1526170656448,
"closeTime": 1526257056448,
"firstId": 42721797,
"lastId": 42939912,
"count": 218116
}
但是当我尝试加载时K 线/烛台数据通过使用此链接:(其中有开始时间 and endTime设置为完全相同openTime and 关闭时间在上面的回复中)。结果是:
[
[
1526171400000, // Open time
"0.00154030", // Open
"0.00154560", // High
"0.00153600", // Low
"0.00153780", // Close
"5716.55000000", // Volume
1526172299999, // Close time
"8.79961911", // Quote asset volume
729, // Number of trades
"2149.12000000", // Taker buy base asset volume
"3.30996242", // Taker buy quote asset volume
"0" // Ignore
],
.......
[
1526256900000,
"0.00150450",
"0.00150680",
"0.00150430",
"0.00150590",
"985.40000000",
1526257799999,
"1.48381883",
198,
"508.80000000",
"0.76612330",
"0"
]
就价格变化百分比而言,我尝试使用以下方法计算最后区间的收盘价和第一个区间的开盘价(0.00150590 / 0.00154030 - 1 = -2.2%),但结果 -2.2% 与 24 小时股票价格变化统计中的 "priceChangePercent": "1.314" 完全不同。
我的问题是,Binance API 如何计算 K 线/烛台数据在 24 小时内的价格变化百分比?谢谢你花时间做很多事情。