historical API outputs garbage data for dates older than the IPO

For example, AFFLE had its IPO in July of 2019.
For any from_date < IPO date, we should expect an empty list as the output.
But for some reason I get a non-zero junk data for range 2015-03-07 to 2015-05-06
See below code snippet.

To Recreate:

In [2]: import datetime

In [3]: from_date = datetime.datetime(2015, 3, 7)

In [4]: to_date = datetime.datetime(2015, 5, 6)

In [5]: token=2903809

In [6]: data = kite.historical_data(token, from_date=from_date, to_date=to_date, interval='5minute')

In [7]: len(data)
Out[7]: 2844

In [8]: data[0:10]

[{'date': datetime.datetime(2015, 3, 9, 9, 15, tzinfo=tzoffset(None, 19800)),
'open': 17.95,
'high': 17.95,
'low': 17.95,
'close': 17.95,
'volume': 0},
{'date': datetime.datetime(2015, 3, 9, 9, 20, tzinfo=tzoffset(None, 19800)),
'open': 17.95,
'high': 18,
'low': 17.95,
'close': 18,
'volume': 108},
  • Vivek
    Seems like instrument token (2903809) might have been assigned to some other instrument during that period by exchange and it might not be trading now. This is a known issue. exchange assigns defunct token to new instruments. Will let you know when we come up with some fix.
  • niteshb1030
    One solution might be to return the instrument name along with the ohlc data.
    This way user can cross check if he is receiving the data for the desired instrument.
Sign In or Register to comment.