Originally published at: Create Trading Candlesticks from a Websocket with Python | EODHD APIs Academy
Introduction This method will work with any websocket data containing a timestamp and price. I’m going to demonstrate this using EODHD’s “crypto” websocket end-point. It’s important to note that websocket end-points for different asset types may be presented differently. If that is the case you will need to make the adjustments to the code. For example in the cryptocurrencies end-point the price is represented as “p” and the timestamp is represented as “t” as a UNIX timestamp. If you are going to try this with the “us”, “us-quote”, or “forex” end-points, you need to make sure this looks the same for those end-points. If it isn’t, then just map the fields accordingly. It would also be worth checking the format…
Useful example! I’ll try to make candles via WebSocket, I hope it works!
Interesting, but it would be worth adding more information on error handling, otherwise the connection may drop.
The step-by-step approach in this article is spot on. I’ve read a few other resources, but this one finally clicked for me. Looking forward to more tutorials like this!
I tried it on crypto, and it works, but the code is a bit complicated.
Has anyone tried connecting this to longer intervals, like hourly? I’m using minute ones for now, but I’d like to see how it works on longer periods. I hope it works.
Step by step it’s ok, but with WebSocket there are interruptions. I’ll have to add a restart.
Not a very necessary thing
Cool, but add an example with indicators! Only candles, not enough analysis.
I put it to the test, and it works, but sometimes it lags. Maybe there are problems with the Internet.