作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发自己的应用程序,我想在其中检索 24 小时内的价格数据。我已阅读币安在 https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md 提供的文档
然后我尝试使用链接 https://api.binance.com/api/v1/ticker/24hr?symbol=BTCUSDT 获取 24 小时股票价格变化统计信息 。回应是:
{
"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
}
[
[
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"
]
最佳答案
不,它是:
priceChangePercent = (lastPrice - openPrice )/(openPrice)
如果 lastPrice 大于 openprice
(openPrice - lastPrice)/(openPrice) 会给你一个负百分比!
关于api - Binance API 如何在 24 小时内计算 priceChangePercent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50321891/
我正在开发自己的应用程序,我想在其中检索 24 小时内的价格数据。我已阅读币安在 https://github.com/binance-exchange/binance-official-api-do
我是一名优秀的程序员,十分优秀!