【发布时间】:2017-12-20 16:57:47
【问题描述】:
我想从 Bitfinex websocket API 检索多个股票通道的 JSON 数据,但似乎我只能连接到一个货币对。
我怎样才能做到多对?
这是一对的示例代码:
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]);
}
};
【问题讨论】:
标签: javascript api websocket