Skip to content

Instantly share code, notes, and snippets.

@vmesel
Created December 20, 2017 19:24
Show Gist options
  • Select an option

  • Save vmesel/63f14aea49a46bb5c8b819ab8901f2fb to your computer and use it in GitHub Desktop.

Select an option

Save vmesel/63f14aea49a46bb5c8b819ab8901f2fb to your computer and use it in GitHub Desktop.
import json
import websocket
ws = websocket.WebSocket()
ws.connect("wss://api.bitfinex.com/ws/2")
ws.send(json.dumps({
"event":"subscribe",
"channel":"book",
"pair":"BTCUSD",
}))
while True:
msg = ws.recv()
if "msg" in msg:
if msg["msg"] == "Stopping. Please try to reconnect":
ws.send(json.dumps({
"event":"subscribe",
"channel":"book",
"pair":"BTCUSD",
}))
print(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment