Hi,
I am trying to subscribe to 300 Ticks chart. All I require at the end of the day is latest 3 candles (300 Ticks) at the moment. I also want to know when a new candle is formed (As soon as it is formed. Quicker is better).
What I tried:
-
Subscribed to Real Time using md/getChart and kept receiving data using ws.recv at regular intervals of 1 second. Here, ws is created using “create_connection” from “websocket” library of python. This gives delay in receiving the ticks. In real, 300 ticks pass quickly and ws.recv takes one tick at a time. The delay adds up slowly so that I get delays of over a minute within first few minutes of my script.
-
I then tried to subscribe and get historical candles (3 candles) and send “cancelChart” at the same time and a new request to getChart with similar details. What I am trying to achieve is, get latest 3 candles from historic data and then cancel that subscription right away when I get “eoh”:True. Then subscribe again to get latest 3 candles from historic candles and so on. The issue here is that when I cancel and send new subscription request, it takes more than 10-20 seconds to take effect. Cancellation of old realTime data takes time and I keep receiving ticks through ws.recv(). This also makes the script useless.
Can you share a better alternative for this implementation? All I need is latest 3 candles (300 Ticks) and need to find distinctly when an ongoing candle has been formed completely and new one is started to Form (Need to know that as soon as the event occurred. An event based solution can work).
Looking forward to your responses.
Thanks,
Pratik