Inconsistent reponse from kite.historical_data()

krishnakant
krishnakant edited May 2018 in Python client
Hi,

Is the "from" date and "to" date inclusive of the request?

I made the api call and the response includes penultimate tick but not the "to" date. However, when I tried the same call for the day which is ongoing, the response includes the "to" date.

Example -
(1) For May 29 - The response returns 14:55 as the last tick
Request - kite.historical_data(1510401, '2018-05-29 14:50:00', '2018-05-29 14:56:00', 'minute')
Response - [{'volume': 10560, 'high': 547.4, 'low': 546.45, 'date': datetime.datetime(2018, 5, 29, 14, 50, tzinfo=tzoffset(None, 19800)), 'close': 546.75, 'open': 546.6}, {'volume': 8961, 'high': 547.5, 'low': 546.65, 'date': datetime.datetime(2018, 5, 29, 14, 51, tzinfo=tzoffset(None, 19800)), 'close': 547.3, 'open': 546.75}, {'volume': 29687, 'high': 547.7, 'low': 547.15, 'date': datetime.datetime(2018, 5, 29, 14, 52, tzinfo=tzoffset(None, 19800)), 'close': 547.55, 'open': 547.3}, {'volume': 16105, 'high': 547.8, 'low': 546.8, 'date': datetime.datetime(2018, 5, 29, 14, 53, tzinfo=tzoffset(None, 19800)), 'close': 547.4, 'open': 547.5}, {'volume': 12921, 'high': 547.7, 'low': 546.85, 'date': datetime.datetime(2018, 5, 29, 14, 54, tzinfo=tzoffset(None, 19800)), 'close': 547.45, 'open': 547.25}, {'volume': 13984, 'high': 547.75, 'low': 547.3, 'date': datetime.datetime(2018, 5, 29, 14, 55, tzinfo=tzoffset(None, 19800)), 'close': 547.45, 'open': 547.45}]


(2) For May 30 - The response returns 14:56 as the last tick
Request - kite.historical_data(1510401, '2018-05-30 14:50:00', '2018-05-30 14:56:00', 'minute')
Response - [{'volume': 3632, 'high': 541.9, 'low': 541.5, 'date': datetime.datetime(2018, 5, 30, 14, 50, tzinfo=tzoffset(None, 19800)), 'close': 541.8, 'open': 541.8}, {'volume': 5597, 'high': 542, 'low': 541.65, 'date': datetime.datetime(2018, 5, 30, 14, 51, tzinfo=tzoffset(None, 19800)), 'close': 542, 'open': 541.8}, {'volume': 3989, 'high': 542, 'low': 541.2, 'date': datetime.datetime(2018, 5, 30, 14, 52, tzinfo=tzoffset(None, 19800)), 'close': 541.5, 'open': 542}, {'volume': 13453, 'high': 541.6, 'low': 540.9, 'date': datetime.datetime(2018, 5, 30, 14, 53, tzinfo=tzoffset(None, 19800)), 'close': 541.05, 'open': 541.6}, {'volume': 14857, 'high': 541.8, 'low': 540.7, 'date': datetime.datetime(2018, 5, 30, 14, 54, tzinfo=tzoffset(None, 19800)), 'close': 541.75, 'open': 540.95}, {'volume': 4453, 'high': 541.9, 'low': 541.1, 'date': datetime.datetime(2018, 5, 30, 14, 55, tzinfo=tzoffset(None, 19800)), 'close': 541.75, 'open': 541.75}, {'volume': 8323, 'high': 541.95, 'low': 541.4, 'date': datetime.datetime(2018, 5, 30, 14, 56, tzinfo=tzoffset(None, 19800)), 'close': 541.7, 'open': 541.75}]

Thanks,
  • sujith
    It can happen because server clock might not be in sync with your clock.
    You can check out this thread for more information.
  • krishnakant
    @sujith my question is different. I understand that the last minute candle might not be synced with the clock time at my end.

    However, the date interval inclusion should be consistent. Even if you make the API request right now (after market hours), you would still get the above response. My issue concerns whether the "to" date is included in the response data or not.

    For example, when I define an interval from 1 to 10, my question is it a [1,10] or [1,10) interval. This policy should be consistent irrespective of server time.
  • sujith
    Are you referring to intraday candles or day candles?
  • sujith
    Can you paste an example request params here?
  • krishnakant
    I am referring to minute candles (intraday).

    For example -
    When you run the below in Python for May 30 (today)-
    kite.historical_data(1510401, '2018-05-30 14:50:00', '2018-05-30 14:52:00', 'minute')
    This will return candles from 14:50 to 14:52 (3 candles in total)

    However, when you run the below for May 29 (same time intervals) -
    kite.historical_data(1510401, '2018-05-29 14:50:00', '2018-05-29 14:52:00', 'minute')
    This will return candles from 14:50 to 14:51 (2 candles in total)

    This is inconsistent as the interval length should be precisely defined irrespective of anything else.

    PS - This might change when you run it on May 31 (tomorrow). To get similar results, make one API request for the latest trading day (today) and another on previous/past trading days.
  • sujith
    I have informed data team they are looking into this.
  • krishnakant
    Thank you. Waiting for resolution.
  • krishnakant
    @sujith, any update on this?
  • sujith
    @krishnakant,
    Our data team is working on it. It will take some more since this requires some architectural changes.
  • sujith
    We will update here once it is fixed.
Sign In or Register to comment.