JSFiddle - React, Tailwind, and code Playground
by humanzing
JavaScript
var OrderBook = [];
var Bitfinex = [];
OrderBook.push(["Bitfinex",Bitfinex]);
Push_in(OrderBook,"Bitfinex","test");
//OrderBook.Bitfinex.push("test");
console.log(OrderBook);
function Push_in(arr, name, data, price, count)
{
OrderBook.forEach(function(el)
{
if (el[0] == name)
{
el[1].forEach(function(els)
{
if (els[1] == price)
{
if (els[2] > count)
{
els[2] = count;
}
else if (els[2] < count)
{
els[2] = count;
}
else {}
}
});
}
});
}
bitfinexWS = new WebSocket("wss://api-pub.bitfinex.com/ws/2");
bitfinexWS.onmessage = function(e) {
console.log(e.data)
};
let msg = JSON.stringify({
event: 'subscribe',
channel: 'book',
symbol: 'tBTCUSD'
})
bitfinexWS.onopen = function() {
websocket.send(msg);
};