Created
August 31, 2017 23:20
-
-
Save mcohen01/57f81fafc448cde468f30412d7a3d863 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
import websocket # pip install websocket_client | |
import _thread | |
import json | |
def main(): | |
def on_open(ws): | |
def run(*args): | |
msg = { | |
'type': 'subscribe', | |
'product_ids': ['ETH-USD'] | |
} | |
ws.send(json.dumps(msg)) | |
_thread.start_new_thread(run, ()) | |
websocket.enableTrace(True) | |
url = "wss://ws-feed.gdax.com" | |
f = lambda ws, msg: print(msg) | |
ws = websocket.WebSocketApp(url, on_message = f) | |
ws.on_open = on_open | |
ws.run_forever() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment