Skip to content

Instantly share code, notes, and snippets.

@auxiliary-character
Last active December 15, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auxiliary-character/5333526 to your computer and use it in GitHub Desktop.
Save auxiliary-character/5333526 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import websocket
import json
def on_message(ws, message):
print("\n\n{0}".format(message))
def on_error(ws, error):
print("\n\n##Error##\n\n{0}".format(error))
def on_disconnect(ws):
print("\n\n##Disconnected##")
def on_connect(ws):
ws.send(json.dumps({"op":"mtgox.subscribe",
"type":"trades"}))
print("##Connection Established##")
if __name__ == "__main__":
ws = websocket.WebSocketApp("wss://websocket.mtgox.com/mtgox?Currency=USD",
on_message=on_message,
on_error=on_error,
on_close=on_disconnect)
ws.on_open = on_connect
ws.run_forever()
@auxiliary-character
Copy link
Author

Seems to be disconnecting a lot…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment