Close values returned from the historical API don't match with those displayed on the kite web app

Shreyas
I am using the nodejs client for fetching historical data. Close values returned by the API don't match with those shown on Kite web.
Example, close value of asian paint sept fut (12492546) for 1 day candle on 26 August as per web is 3045.05 (see top center of cahrt) while that returned from the API is 3035.5 (Refer the screenshots). Also, other values from the series don't match as well except the last close.





Code used for fetching values, (here, instance is instance of KiteConnect class)

this.instance
.getHistoricalData(parseInt(instToken), "day", from, today, true)
.then((result: HistRes[]) => {
console.log(result);

return result.reverse();
})
  • Shreyas
    Similar issue with ADANI PORTS SEPT FUT (12485634)
  • rakeshr
    We just checked for the same period and it's matching fine. You would be requesting for wrong period.
    "candles": [
    [
    "2021-08-26T00:00:00+0530",
    3057.3,
    3089.9,
    3032.85,
    3045.05,
    1504800
    ]
    ]
  • Shreyas
    Strange !! :/
    Thanks for the quick turnaround. I checked again at my side, but still getting thr incorrect values. This time I tried with all literal values, but the output is same.

    Code


    public getHistoricalData = async (): Promise<HistRes[]> => {
    return this.instance
    .getHistoricalData(
    12492546,
    "day",
    "2021-08-16 00:00:00",
    "2021-08-31 00:00:00",
    true
    )
    .then((result: HistRes[]) => {
    console.log(result);
    return result.reverse();
    });
    };

    Output


    [
    {
    date: 2021-08-15T18:30:00.000Z,
    open: 2974.95,
    high: 2983.55,
    low: 2958,
    close: 2971.6,
    volume: 544800
    },
    {
    date: 2021-08-16T18:30:00.000Z,
    open: 2978.7,
    high: 3042,
    low: 2973.95,
    close: 3021.2,
    volume: 2446200
    },
    {
    date: 2021-08-17T18:30:00.000Z,
    open: 3042.55,
    high: 3046.65,
    low: 3000.5,
    close: 3008.05,
    volume: 1430100
    },
    {
    date: 2021-08-19T18:30:00.000Z,
    open: 3000.55,
    high: 3119.75,
    low: 2999.5,
    close: 3108.6,
    volume: 4359600
    },
    {
    date: 2021-08-22T18:30:00.000Z,
    open: 3150.5,
    high: 3155.45,
    low: 3052.8,
    close: 3074.95,
    volume: 2595000
    },
    {
    date: 2021-08-23T18:30:00.000Z,
    open: 3094.8,
    high: 3094.85,
    low: 3038.95,
    close: 3051.2,
    volume: 1752300
    },
    {
    date: 2021-08-24T18:30:00.000Z,
    open: 3036.5,
    high: 3071.7,
    low: 3015.4,
    close: 3040.25,
    volume: 1690800
    },
    {
    date: 2021-08-25T18:30:00.000Z,
    open: 3049.95,
    high: 3079,
    low: 3022,
    close: 3035.5,
    volume: 742800
    },
    {
    date: 2021-08-26T18:30:00.000Z,
    open: 3049.35,
    high: 3061.15,
    low: 3026,
    close: 3046.95,
    volume: 789600
    },
    {
    date: 2021-08-29T18:30:00.000Z,
    open: 3059.85,
    high: 3117.75,
    low: 3058.3,
    close: 3112.65,
    volume: 1399500
    }
    ]



    Could you please check again? This is causing my analysis to drift a lot.
  • rakeshr
    I just checked for the same request
    kc.getHistoricalData(12492546, 'day', "2021-08-16 00:00:00", "2021-08-31 00:00:00", true)
    .then(function(response) {
    console.log(response);
    }).catch(function(err) {
    console.log(err);
    });
    },
    {
    date: 2021-08-24T18:30:00.000Z,
    open: 3048.45,
    high: 3081,
    low: 3027,
    close: 3050.7,
    volume: 1851600
    },
    {
    date: 2021-08-25T18:30:00.000Z,
    open: 3057.3,
    high: 3089.9,
    low: 3032.85,
    close: 3045.05,
    volume: 1504800
    },


    It's showing fine at my end. Also, all your response seems to be wrong for a required interval not just for 26th.
    P.S: If you are concerned about difference in timezone info 2021-08-25T18:30:00.000Z, for node client. It's because of default nature of Date object in js.
  • Shreyas
    Hi @rakeshr @sujith ,
    I have created a minimum running example for the issue. This bare minimum code should return the correct values for close and volume for asianpaint sept future, however it does not.

    This gist also has instructions to run the code.
    https://gist.github.com/shreyas1496/b635c68fc0da0072a66c8cb65cb96c65

  • Shreyas
    Hi @rakeshr @sujith , any update on the above post?
  • rakeshr
    kc.getHistoricalData(
    12492546,
    "day",
    "2021-08-16 00:00:00",
    "2021-08-31 00:00:00",
    true
    )
    This difference is coming up because you are requesting for continuous data(continuous=True(last param field above)).
    So, how continuous data works is, it shows that months active contract day candle data for that period i.e here above value is for ASIANPAINT21AUGFUT.
    So, if you want candle data for a specific contract only, you need to avoid requesting continuous data.
    kc.getHistoricalData(
    12492546,
    "day",
    "2021-08-16 00:00:00",
    "2021-08-31 00:00:00"
    )
  • Shreyas
    Hi @rakeshr , @Vivek, @sujith ,

    The above range (15 days) is just added for the sake of providing an example. Actually, I need to fetch last 6 months data. Therefore, I am using the continuous flag to get values of previous months as well.

    For a given day of which trading session has ended (say, 26 August) for ASIANPAINT21SEPFUT, the close value and volume should not change, whether it is requested with continous flag set or unset. The problem here is the close value and volume are different when the continous flag is set or unset.

    Let me know whether or not you aggree with my above claim.

    P.S. This is not an issue with the nodejs client, the underlying API itself is returning incorrect values.
Sign In or Register to comment.