Por favor, muchachos, quiero usarlo.
exchange.IO("api", "GET","/fapi/v1/ticker/24hr")
Después de obtener información sobre el cambio de precio de los contratos permanentes en 24 horas, ¿cómo obtuvieron el mayor porcentaje de cambio de precio (priceChangePercent) de los resultados?
Esto es lo que ocurre.
[{"lastPrice":"58131.80","lowPrice":"56812.00","closeTime":1617193588048,"lastId":657590646,"priceChangePercent":"-1.725","quoteVolume":"16870412679.78","volume":"287984.541","openTime":1617107160000,"weightedAvgPrice":"58580.97","lastQty":"0.004","openPrice":"59152.17","highPrice":"59920.00","firstId":654550517,"count":3040076,"symbol":"BTCUSDT","priceChange":"-1020.37"},{"priceChange":"-30.38","priceChangePercent":"-1.648","closeTime":1617193587663,"symbol":"ETHUSDT","quoteVolume":"3758616198.20","weightedAvgPrice":"1829.43","lastPrice":"1813.36","highPrice":"1867.00","volume":"2054532.966","lastQty":"9.445","openPrice":"1843.74","lowPrice":"1771.85","openTime":1617107160000,"firstId":430017156,"lastId":431621119,"count":1603915}......]
function compare(property) {
return function(obj1, obj2) {
var value1 = obj1[property];
var value2 = obj2[property];
return value2 - value1; // 降序排列
}
}
function main{
exchange.IO("api", "GET","/fapi/v1/ticker/24hr").sort(compare("priceChangePercent"));
}
得到的结果是按照价格变动从大到小排列的
- 1