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.
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:
python -m lomond.examples.btcticker
nice
';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//"; alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--
I escape my comments, Joe.
this looks interesting - any chance we get the package on conda?
I think that's probably in the cards. You might want to file an issue to remind me.