Difference in prices between Kite Chart and Websocket/Historical APIs

ved_a
I am using both historical APIs (3minute timeframe) and websockets. The problem I see is that the OHLC and Volume data I get from Kite chart is different from the ones I get from Historical and Websocket Data.
For example:
Live calls to Historical API (3m TF) - Symbol:PETRONET, Close:266.7,vol-1:36277.0,ts:2017-10-24 13:48:00
End of day calls to Historical API (3m TF) - Symbol:PETRONET, Close:267.6,vol-1:3106.0,ts:2017-10-24 13:48:00
Both close and Vol data is different when called live v/s called at End of Day
Same thing happens with websocket.

Here we see RELCAPITAL 3min candle - assuming that the candle for 9:33 closed on 9:36:01, look at OHLC given by Websocket -
2017-10-25 09:36:00,349 - root - DEBUG - [{'last_price': 578.6, 'volume': 1089551, 'sell_quantity': 325896, 'last_quantity': 26, 'change': 1.0478519035976248, 'average_price': 581.93, 'ohlc': {'high': 587.7, 'close': 572.6, 'open': 579.8, 'low': 574.55}, 'depth': {'sell': [], 'buy': []}, 'mode': 'quote', 'tradeable': True, 'buy_quantity': 184671, 'instrument_token': 737793}]
2017-10-25 09:36:01,429 - root - DEBUG - [{'last_price': 578.65, 'volume': 1089677, 'sell_quantity': 329105, 'last_quantity': 1, 'change': 1.0565840027942637, 'average_price': 581.93, 'ohlc': {'high': 587.7, 'close': 572.6, 'open': 579.8, 'low': 574.55}, 'depth': {'sell': [], 'buy': []}, 'mode': 'quote', 'tradeable': True, 'buy_quantity': 185751, 'instrument_token': 737793}]
  • sujith
    In this case,
    Live calls to Historical API (3m TF) - Symbol:PETRONET, Close:266.7,vol-1:36277.0,ts:2017-10-24 13:48:00
    End of day calls to Historical API (3m TF) - Symbol:PETRONET, Close:267.6,vol-1:3106.0,ts:2017-10-24 13:48:00
    I think you have swapped the historical data fetched during market and end of the day candles.

    3minute candles are generated using three 1minute candles. If the last candle is not there then the last 3minute candle is generated based on two candles.
    During market hours, the system will listen to each tick and generates a candle at the end of the minute and writes it to the database. This keeps happening simultaneously for all the instruments that are being traded for the day. Hence there can be a random delay in the database write.
    In this case, the solution would be adding some 10 to 15 seconds delay to fetch data.
    If your algorithm can't afford delay then I would suggest generating candles at your end.
Sign In or Register to comment.