Getting wrong historical data

shivamkr_jaiswal
while fetching daily ohlc, got wrong data. Same is happening for different timeframe. It is not matching

TCS:
date open high low close volume
2020-06-22 00:00:00+05:30 2045.05 2050.0 2020.0 2031.1 210260

5minute:

date open high low close volume
69 2020-06-22 15:00:00+05:30 2023.6 2025.0 2023.0 2024.2 1717
70 2020-06-22 15:05:00+05:30 2024.2 2028.5 2022.8 2028.0 7360
71 2020-06-22 15:10:00+05:30 2028.0 2030.05 2026.85 2030.0 5221
72 2020-06-22 15:15:00+05:30 2030.0 2032.7 2026.0 2031.35 3401
73 2020-06-22 15:20:00+05:30 2031.35 2031.85 2027.6 2030.15 2175
74 2020-06-22 15:25:00+05:30 2030.0 2032.0 2030.0 2031.1 4295
  • shivamkr_jaiswal
    Using below code snippet:

    def getHistoricalData(symbol, days, interval):
    # minute, 3minute, 5minute, 10minute, 15minute, 30minute, 60minute, day
    instrumenttoken = getInstrumentToken(symbol)
    fromdate = date.today()-timedelta(days=days)
    todate = date.today()
    historicaldata = kite.historical_data(instrumenttoken, fromdate, todate, interval)
    data = pd.DataFrame(historicaldata)
    #data.set_index('date', inplace=True)
    return data

    getHistoricalData('TCS', 20, 'day')
    getHistoricalData('TCS', 5, '5minute')
  • rakeshr
    @shivamkr_jaiswal
    while fetching daily ohlc, got wrong data. Same is happening for different timeframe. It is not matching
    Can you let us know the reference data from which you are comparing to?
  • shivamkr_jaiswal
    I am comparing from Kite chart. Look at the volume. What i got is 210260, while it is actually around 32lakhs. Also day low should be 2019.75 as per kite chart, but i got 2020.

  • shivamkr_jaiswal
    Can someone help why am I getting data which is not matching with kite charting data.

    Extracted Mindtree Daily data.
    OHLC and volume has discrepancy.

    date open high low close volume
    0 2020-06-03 00:00:00+05:30 935.0 936.0 904.9 908.5 49240
    1 2020-06-04 00:00:00+05:30 928.5 939.75 905.1 934.75 89702
    2 2020-06-05 00:00:00+05:30 944.9 945.5 917.0 918.95 45158
    3 2020-06-08 00:00:00+05:30 925.9 930.85 909.35 918.4 30312
    4 2020-06-09 00:00:00+05:30 920.35 926.1 887.05 897.25 34067
    5 2020-06-10 00:00:00+05:30 905.0 916.45 858.4 909.2 89746
    6 2020-06-11 00:00:00+05:30 910.0 924.7 896.0 919.15 31837
    7 2020-06-12 00:00:00+05:30 891.0 918.0 887.6 913.55 17226
    8 2020-06-15 00:00:00+05:30 907.4 930.5 903.05 922.95 29351
    9 2020-06-16 00:00:00+05:30 931.0 935.3 908.15 912.2 31687
    10 2020-06-17 00:00:00+05:30 930.0 930.0 902.95 906.15 123022
    11 2020-06-18 00:00:00+05:30 915.6 918.8 900.3 907.4 19688
    12 2020-06-19 00:00:00+05:30 905.0 934.0 898.35 912.75 47499
    13 2020-06-22 00:00:00+05:30 915.65 921.7 900.0 909.45 14240
    14 2020-06-23 00:00:00+05:30 897.0 938.0 897.0 926.2 54199

    Used below code. Previously there was no issue. Data extraction was accurate using this same code snippet.

    def getHistoricalData(symbol, days, interval):
    # minute, 3minute, 5minute, 10minute, 15minute, 30minute, 60minute, day
    instrumenttoken = getInstrumentToken(symbol)
    fromdate = date.today()-timedelta(days=days)
    todate = date.today()
    historicaldata = kite.historical_data(instrumenttoken, fromdate, todate, interval)
    data = pd.DataFrame(historicaldata)
    return data

    getHistoricalData('MINDTREE', 20, 'day')
  • rakeshr
    @shivamkr_jaiswal
    instrumenttoken = getInstrumentToken(symbol)
    You are fetching BSE instrument_token of TCS and comparing it with TCS-NSE chart data.
    Modify your getInstrumentToken method to return only NSE instrument for requested Symbol. Might add,filter condition of exchange=='NSE' in above method.
Sign In or Register to comment.