Skip to content

Instantly share code, notes, and snippets.

@mcohen01
Created August 31, 2017 23:20
Show Gist options
  • Save mcohen01/57f81fafc448cde468f30412d7a3d863 to your computer and use it in GitHub Desktop.
Save mcohen01/57f81fafc448cde468f30412d7a3d863 to your computer and use it in GitHub Desktop.
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