Stream BTC prices over WebSockets with Python and Lomond

WebSockets is a great technology with many applications beyond the front end. I have a feeling that websocket APIs will become far more common in the web ecosphere.

I really like this example of how to interact with a WebSockets api with just-released Lomond 0.1.5.

© 2018 Will McGugan Get the code from Lomond repos on Github.

This connects to the gdax websocket server and periodically prints the latest BTC price information. If you change the text "ticker" to "level2" it will spew out information on every trade. You could use this as the foundation for algorithmic trading or to keep an eye on your retirement fund (good luck).

Getting Lomond

Lomond is a websocket client library sponsored by Dataplicity. It has a focus on robustness and ease of use.

Lomond runs on Win / Mac / Linux platforms with Python2.7 or Python3*. You can install Lomond with pip:

pip install lomond

If you want to see the above example in action, run the following: