Incorrect WebSocket data

magger
I am running a script in which I calculate the OHLCV data based upon the live tick data through WebSocket. The code writes the incoming tick onto a local db and subsequently reads whenever a new candle has been created. It has been created using various FAQs posted on the forum itself - https://kite.trade/forum/discussion/2604/convert-ticks-to-candle

The candles are formed using the LTP of the instrument. I am attaching 2 csv files containing the ltp and cumulative volume, the first one containing data as processed by each tick and secondly the candles formed by the tick data.

The instrument in Nifty October Futures.

As one can see the candles using the historical API and shown on charts is vastly different. The opening itself has a massive difference of 7 points.

So -
  1. Can anyone confirm whether the tick data received was right?
  2. If the problem is common what is the solution to the following? I am willing to share the code which stores the ticks and subsequently reads them.
  • rakeshr
    As one can see the candles using the historical API and shown on charts is vastly different. The opening itself has a massive difference of 7 points.
    We use the same WebSocket stream to plot historical candles on the kite charts. So, until you are having some heavy logic/computation while capturing the tick that would be blocking the tick stream or adding the delay. There should be no reason for the difference.
    If the problem is common what is the solution to the following?
    You can go through the kiteconnect resources list, and follow any of the listed down package/examples to store tick async.
  • magger
    Hi @rakeshr. I have gone through n number of legacy threads and recommendations before creating this thread.

    As you've mentioned that this might be caused by heavy logic/computation I ran two other scripts to procure data and create candles. In this code which does nothing but create candles one it stores the incoming ticks in a queue, finally pushing them onto for candle creation. The code which was recommended by other Kite Connect users can be found here - https://gist.github.com/oldmonkABA/f73f5d67bcf85316ac0470919bf54e17. There is still a discrepancy between the candles on Kite charts.

    Even in the db code which I mentioned of earlier, apart from the time when the 5 minute candle is created there is no computation, furthermore even the opening of yesterdays future was different by 7 points. No computation was done during the initial 5 minutes i.e. from 9:15 to 9:20 itself.

    As a last resort I have saved the incoming ticks into a list, exported them and iterated through it locally to create candles. The data still has discrepancy from the Kite charts.

    I am attaching the ticks for Nifty October Futures - 13299458.

    Kindly confirm if the ticks are correct on your end as well so I can try to rectify the error, if any.
  • magger
    Hi @rakeshr here is the data I received for today.




    There is a difference of 8 points in the opening itself and also variations in the Volume. The other methods I tried also pose an error. How can I rectify the error?
Sign In or Register to comment.