Duplicated post market OHLC data for Nifty 50

mlearner
Hi,

Noticing some strange behaviour in Data API today.

Earlier for a day (checked until 23 Nov '20), I used to get exactly 75 candle entries from Historical Data API for 5-min OHLC data for Nifty 50 (9:15 am - 3:30 pm). This is as expected.

Of late, started getting duplicated OHLC data for post market timestamps. Getting 126 entries for 5-min OHLC for a day. 51 junk entries like shown below because of post market repeated candles.

Note: Timestamps below are in UTC.
-------
-------

{ "_id" : ObjectId("5fca506189617b1d51d6770c"), "timestamp" : ISODate("2020-12-04T09:45:00Z"), "open" : 13256.6, "high" : 13260.85, "low" : 13253.65, "close" : 13257.55 }
{ "_id" : ObjectId("5fca506189617b1d51d6770d"), "timestamp" : ISODate("2020-12-04T09:50:00Z"), "open" : 13257.35, "high" : 13271.65, "low" : 13255.45, "close" : 13270.2 }
{ "_id" : ObjectId("5fca506189617b1d51d6770e"), "timestamp" : ISODate("2020-12-04T09:55:00Z"), "open" : 13270.55, "high" : 13276.9, "low" : 13269.4, "close" : 13270.7 }
{ "_id" : ObjectId("5fca506189617b1d51d6770f"), "timestamp" : ISODate("2020-12-04T10:00:00Z"), "open" : 13271.05, "high" : 13271.05, "low" : 13258.55, "close" : 13258.55 }
<b class="Bold">{ "_id" : ObjectId("5fca506189617b1d51d67710"), "timestamp" : ISODate("2020-12-04T10:05:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }
{ "_id" : ObjectId("5fca506189617b1d51d67711"), "timestamp" : ISODate("2020-12-04T10:10:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }
{ "_id" : ObjectId("5fca506189617b1d51d67712"), "timestamp" : ISODate("2020-12-04T10:15:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }
{ "_id" : ObjectId("5fca506189617b1d51d67713"), "timestamp" : ISODate("2020-12-04T10:20:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }
{ "_id" : ObjectId("5fca506189617b1d51d67714"), "timestamp" : ISODate("2020-12-04T10:25:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }
{ "_id" : ObjectId("5fca506189617b1d51d67715"), "timestamp" : ISODate("2020-12-04T10:30:00Z"), "open" : 13258.55, "high" : 13258.55, "low" : 13258.55, "close" : 13258.55 }</b>
-------
-------
I am giving below as timestamp -

from_date = datetime.datetime(2020, 12, 4)
to_date = datetime.datetime(2020, 12, 5)
data = kite.historical_data(constants.NIFTY50_INSTRUMENT_TOKEN, from_date, to_date, '5minute')

Even if I am giving exact timestamp as per market opening / closing time, I am getting truncated entries starting from 12:30 pm IST and till 3:30 pm IST. This is again a weird behaviour.

from_date = datetime.datetime(2020, 12, 4,3,45,0)
to_date = datetime.datetime(2020, 12, 4,10,0,0)
-----
-----
0 2020-12-04 07:00:00+05:30 13133.90 13133.90 13133.90 13133.90 0
1 2020-12-04 07:05:00+05:30 13133.90 13133.90 13133.90 13133.90 0
2 2020-12-04 07:10:00+05:30 13133.90 13133.90 13133.90 13133.90 0
3 2020-12-04 07:15:00+05:30 13133.90 13133.90 13133.90 13133.90 0
4 2020-12-04 07:20:00+05:30 13133.90 13133.90 13133.90 13133.90 0
5 2020-12-04 07:25:00+05:30 13133.90 13133.90 13133.90 13133.90 0
6 2020-12-04 07:30:00+05:30 13133.90 13133.90 13133.90 13133.90 0
7 2020-12-04 07:35:00+05:30 13133.90 13133.90 13133.90 13133.90 0
8 2020-12-04 07:40:00+05:30 13133.90 13133.90 13133.90 13133.90 0
9 2020-12-04 07:45:00+05:30 13133.90 13133.90 13133.90 13133.90 0
10 2020-12-04 07:50:00+05:30 13133.90 13133.90 13133.90 13133.90 0
11 2020-12-04 07:55:00+05:30 13133.90 13133.90 13133.90 13133.90 0
12 2020-12-04 08:00:00+05:30 13133.90 13133.90 13133.90 13133.90 0
13 2020-12-04 08:05:00+05:30 13133.90 13133.90 13133.90 13133.90 0
14 2020-12-04 08:10:00+05:30 13133.90 13133.90 13133.90 13133.90 0
15 2020-12-04 08:15:00+05:30 13133.90 13133.90 13133.90 13133.90 0
16 2020-12-04 08:20:00+05:30 13133.90 13133.90 13133.90 13133.90 0
17 2020-12-04 08:25:00+05:30 13133.90 13133.90 13133.90 13133.90 0
18 2020-12-04 08:30:00+05:30 13133.90 13133.90 13133.90 13133.90 0
19 2020-12-04 08:35:00+05:30 13133.90 13133.90 13133.90 13133.90 0
20 2020-12-04 08:40:00+05:30 13133.90 13133.90 13133.90 13133.90 0
21 2020-12-04 08:45:00+05:30 13133.90 13133.90 13133.90 13133.90 0
22 2020-12-04 08:50:00+05:30 13133.90 13133.90 13133.90 13133.90 0
23 2020-12-04 08:55:00+05:30 13133.90 13133.90 13133.90 13133.90 0
24 2020-12-04 09:00:00+05:30 13133.90 13173.55 13089.35 13164.25 0
25 2020-12-04 09:05:00+05:30 13164.40 13178.05 13162.20 13177.40 0
26 2020-12-04 09:10:00+05:30 13177.40 13177.40 13177.40 13177.40 0
27 2020-12-04 09:15:00+05:30 13177.40 13186.30 13165.20 13182.95 0
28 2020-12-04 09:20:00+05:30 13181.75 13193.20 13180.25 13188.95 0
29 2020-12-04 09:25:00+05:30 13189.30 13195.00 13183.95 13192.25 0
30 2020-12-04 09:30:00+05:30 13192.35 13203.40 13191.25 13203.40 0
31 2020-12-04 09:35:00+05:30 13201.30 13204.00 13194.55 13197.20 0
32 2020-12-04 09:40:00+05:30 13196.90 13212.20 13195.65 13209.65 0
33 2020-12-04 09:45:00+05:30 13210.40 13213.20 13197.40 13202.10 0
34 2020-12-04 09:50:00+05:30 13201.65 13211.75 13199.05 13211.25 0
35 2020-12-04 09:55:00+05:30 13212.40 13215.00 13202.90 13212.00 0
36 2020-12-04 10:00:00+05:30 13212.10 13219.60 13211.20 13218.35 0

-----
-----

Is anything broken in kite.historical_data API?

Thanks.
Tagged:
  • mlearner
    Getting exactly 75 values right now for 5-min OHLC when I am firing Historical Data API with below from time, to time.

    from_date = datetime.datetime(2020, 12, 4)
    to_date = datetime.datetime(2020, 12, 5)

    Was historical API having any issue yesterday with data? And any cleanups done in database?
  • rakeshr
    @mlearner
    Is anything broken in kite.historical_data API? And any cleanups done in database?
    No, nothing is broken. Post-market received data clean-up is done at EOD(end of the day) for Historical data APIs. So, if you don't want to receive any post-market data, you can just send the exact market start and end timestamp for the respective exchange. Something like below:
    from_date = datetime.datetime(2020, 12, 4, 9, 15, 00)
    to_date = datetime.datetime(2020, 12, 4, 15, 30, 00)
Sign In or Register to comment.