Last active
December 15, 2015 22:29
-
-
Save auxiliary-character/5333526 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems to be disconnecting a lot…