In the playground it is possible to subscribe to Raw Books feed, but trying the same in node returns data for Books. I.e. instead of something like
[ 164, [ 5205599654, 7833.5, -0.00409589 ] ]
it returns data like
[ 90, [ 7868.5, 4, 18.073 ] ].
Here is my test case:
var WebSocket = require('ws');
var ws = new WebSocket('wss://api.bitfinex.com/ws/2');
ws.on('error', function(error){
console.log('Bitfinex API connection encountered this error:', error);
});
ws.on('close', function(){
console.log('Bitfinex API connection closed');
});
ws.on('open', function() {
console.log('Bitfinex API connection opened');
// Subscribe to Raw Books
ws.send(JSON.stringify({
"event":"subscribe",
"channel":"book",
"pair":"tBTCUSD",
"perc":"R0"
}));
});
ws.on('message', function(message) {
try {
msg = JSON.parse(message);
console.log(msg); // the message we get does not look like raw books. it is similar to books messages
} catch (e) {
console.error('[bfx ws2 error] received invalid json');
console.error('[bfx ws2 error]', message);
console.trace();
return;
}
});
In the playground it is possible to subscribe to Raw Books feed, but trying the same in node returns data for Books. I.e. instead of something like
[ 164, [ 5205599654, 7833.5, -0.00409589 ] ]
it returns data like[ 90, [ 7868.5, 4, 18.073 ] ]
.Here is my test case: