I want to retrieve JSON data of multiple ticker channels from a Bitfinex websocket API but it seems I can only connect to one currency pair.
How can I do it for multiple pairs?
Here is the sample code for one pair :
var bfx = new WebSocket("wss://api.bitfinex.com/ws");
bfx.onopen = function(){
bfx.send(JSON.stringify({"event":"subscribe","channel":"ticker","pair":"BCHUSD"}));
};
var bchprc=0;
bfx.onmessage = function(msg){
var response = JSON.parse(msg.data);
bchprc = response[1];
if(bchprc!="hb"){
$("#bitfinex_bch_prc").html(response[7]);
}
};