not getting historical data of yesterday

aswin1231
I am not getting yesterday's historical data.

my code


await kc.setAccessToken(locals.access_token);

const hist = await kc.getHistoricalData("134881540", "day", "2024-04-20 00:00:01", "2024-04-25 23:59:59", false, false);

console.log("hist", hist)

output:
hist [
{
date: 2024-04-21T18:30:00.000Z,
open: 402.95,
high: 421.1,
low: 396,
close: 421.1,
volume: 27109
},
{
date: 2024-04-22T18:30:00.000Z,
open: 420.55,
high: 442.15,
low: 416,
close: 427.1,
volume: 54456
}
]

i want to get historical data till yesterday OHLC of a stock. I am rruning this code by 8:30 am and even 9:00 am not getting data.
  • rakeshr
    "2024-04-20 00:00:01", "2024-04-25 23:59:59",
    This thread explains your above query.
  • aswin1231
    @rakeshr

    Are you sure my issue is related to js date object? because i am passing it as string, not from date variable.
    to be on safer side i tried to date as tomorrow's date. of course i tried many combinations.

    I tried the same code at 9:30 am and it worked ( got previous day's data) but not when i tried at 8:00 am or 8:30 or 9:00 am.
  • rakeshr
    Are you sure my issue is related to js date object? because i am passing it as string, not from date variable.
    We don't handle timezone while converting incoming timestamps from upstream (which is in IST). So if your local timezone is in IST then it will just parse the timestamp and show the timezone as IST. You can check the same by checking the last date response for minute interval :
    kc.getHistoricalData("134881540", "minute", "2024-04-20 00:00:01", "2024-04-25 23:59:59", false, false);
    I tried the same code at 9:30 am and it worked ( got previous day's data) but not when i tried at 8:00 am or 8:30 or 9:00 am.
    It worked because your local timezone stamp exceeded today's start date. You can debug the same at your end, from historical data response.
Sign In or Register to comment.