Creating a 1 minute candle from websocket or make a use of historical candles

ankur0101
Hi,
I have written a code in python to create a one minute candle data. But it is not so perfect because sometimes it is missing few ticks when I try to compare it with live data.

I have couple of questions:
1. Can I get latest candle that has been created in a live market using historical data? E.g. whenever time is 11:00:01, I want to fetch the last minute candle i.e. 10:59?

2. Also same with 1 hour candles like to get 14:00 to 15:00 candle right at 15:00:01

Need help.
  • sujith
    Hi @ankur0101,
    Historical data is not meant for live market conditions. It is provided for backtesting only.
    Our systems read all the ticks and generate a candle at the end of the minute and write to the database. It happens for all the instruments that is being traded for the day.
    It is not guaranteed that 10:00:00 AM candle will be available at 10:01:01 AM. There can be a delay because of the database operation.
  • ankur0101
    Thanks @sujith ,

    We want to perform some actions right after formation of hourly candles, what is the maximum amount of delay can occur for forming a hourly candle?

    Thanks
  • sujith
    I am not sure, it is not a fixed delay. It can happen because of anything. If one write slows then the delay can multiply. But it will be a few seconds away. You can try and use it if it is feasible but I would suggest generating candles at your end.
  • ankur0101
    Yes I am generating candles in Python but when I compare its tick with chart putting python console next to chart, I see different ticks and that is why candle stick data from Kite chart is not matching with python generated output.

    Can you please share a python code that is used to generate candles? I will cross check its logic with the one that I have written
  • sujith
    sujith edited January 2018
    The source for our historical data is different from Kite Ticker. The candles generated at your end will never exactly match the candles of Historical data. It will be near but not the exact match.
    Check out this thread for more information.
  • ankur0101
    Thanks @sujith , so which on gives accuracy? Historical data or websocket ticker?
  • sujith
    The data constructed using both the sources are correct. It is just they won't exactly match because of the above-mentioned reason, it will be near.
    In order to get accurate data, you need to have colo setup at exchange which might cost around 18 lakh per annum.
Sign In or Register to comment.