Historical API skipping one day in day timeframe

I am trying to fetch data from x date to y date in day timeframe, but I am getting data from X + 1 day. below are the details.

kite.historical_data(tick['instrument_token'], month_start_timestamp.replace(hour = 8, minute = 0), now().date(), 'day')[0]

datetime.datetime(2024, 4, 1, 8, 0),
datetime.datetime(2024, 5, 22, 11, 16, 28, 267521),

data is coming from 2nd apr.
  • sujith
    You need to send a proper date object with IST(+0530) timezone and 09:15:00
  • balajibetadur
    Could you please share the sample code? because I am passing dates using datetime.now(), but still missing first day data.
  • sujith
    You can check out the example here.
    I think your system timezone is not IST. Either you can set it to IST or you need to set the timezone to IST after creating the date object.
  • balajibetadur

    cross verified the timezone, but I already have the IST time zone set on my device.
  • balajibetadur
    the issue was solved when I removed time from DateTime and passed just date, could you please explain why is this happening?
  • sujith
    You can enable debug logs for pykiteconnect and check the request and response json logs.
  • sujith
    It is because the day candles will have a time as 00:00:00 and any request for after that time is considered. Hence you are getting the next day candle.
  • sujith
    I just got to know this from the team. It should have time for intraday candles but for day candles time is 00:00:00
Sign In or Register to comment.