I would like to know the rate at which the orderbook index process bar shown in red and green is filled.
We confirmed that the rate at which index process bar is created is (amount / total amount of the price). The ratio of the XRP/BTC spot and the ratio of the ETH/BTC spot are different. XRP/BTC multiplied by approximately 2.2 magnifications gives a similar value; ETH/BTC displays a smaller graph. I'm curious about this standard. Where can I get my data?
// xrp/btc spot
const asks = [
['0.0000193', '5820', '0', '4', 5820, -10.52],
['0.00001931', '41288', '0', '7', 47108, -74.59],
['0.00001932', '36323', '0', '10', 83432, -65.62],
['0.00001933', '9181', '0', '3', 92614, -19.59],
['0.00001934', '13273', '0', '5', 105887, -23.98],
['0.00001935', '400', '0', '1', 106287, -0.73],
['0.00001936', '14064', '0', '1', 120352, -25.41],
['0.00001937', '72', '0', '1', 120424, -0.14],
['0.00001938', '109', '0', '2', 120533, -0.2]
]
const sumPrice = asks.reduce((prev, cur) => {
prev += Number(cur[0]);
return prev;
}, 0);
const sumAmount = asks.reduce((prev, cur) => {
prev += Number(cur[1]);
return prev;
}, 0);
const sumOrder = asks.reduce((prev, cur) => {
prev += Number(cur[3]);
return prev;
}, 0);
console.log(`Price: ${sumPrice} / Amount: ${sumAmount} / Order: ${sumOrder}`);
const percent = asks.map(ask => {
return -Number(((Number(ask[1])/sumAmount * 100) * 2.2).toFixed(2));
});
console.log(percent)
i found https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel. and connect data.