Skip to content

Instantly share code, notes, and snippets.

@prdn
Last active April 7, 2020 14:00
Show Gist options
  • Save prdn/855be71284087a617f9cdb58882ef76d to your computer and use it in GitHub Desktop.
Save prdn/855be71284087a617f9cdb58882ef76d to your computer and use it in GitHub Desktop.
bfx-perf-books-v2.1
// INSTALL
// requirements: node.js interpreter
// run: npm install ws
// Subscribe to BTCUSD book on Bitfinex's WebSocket v2
const WS = require('ws')
const w = new WS("wss://api-pub.bitfinex.com/ws/2")
w.onmessage = function(msg) { console.log(Date.now(), msg.data) }
w.onopen = function() {
w.send(JSON.stringify({ "event": "subscribe", "channel": "book", "symbol": "tBTCUSD", "prec": "R0", "len": 100 }))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment