Closed NarendranKT closed 2 months ago
I tried on getting past 7 days report of NIFTY50 stock OHLC data for plotting in chart but timestamp in the response data is fixed to JAN 20. Can you fix it or is there any solution pls reply back!
`try { const symbol = req.params.symbol
const sevenDaysAgo = new Date(Date.now() - 1 * 24 * 60 * 60 * 1000) const query = symbol; console.log(sevenDaysAgo); const queryOptions = { period1: sevenDaysAgo, period2: Date.now(), interval: "1m", return: "object" }; const chart = await yahooFinance.chart(query, queryOptions); res.json({ chart }) } catch (error) { res.json(error.message); }`
"tradingPeriods": { "pre": [ [ { "timezone": "IST", "start": "2024-04-03T03:45:00.000Z", "end": "2024-04-03T03:45:00.000Z", "gmtoffset": 19800 } ] ], "post": [ [ { "timezone": "IST", "start": "2024-04-03T10:00:00.000Z", "end": "2024-04-03T10:00:00.000Z", "gmtoffset": 19800 } ] ], "regular": [ [ { "timezone": "IST", "start": "2024-04-03T03:45:00.000Z", "end": "2024-04-03T10:00:00.000Z", "gmtoffset": 19800 } ] ] }
In this trading periods date were correct but timestamp data is set to Jan 20
"timestamp": [ 1712115900, 1712115960, 1712116020, 1712116080, 1712116140] console.log(new Date(1712115900)); //OUTPUT : 1970-01-20T19:35:15.900Z
sorry for inconvince, I forgot to multiply the timestamp with 1000.
Bug Report
BUG
I tried on getting past 7 days report of NIFTY50 stock OHLC data for plotting in chart but timestamp in the response data is fixed to JAN 20. Can you fix it or is there any solution pls reply back!
`try { const symbol = req.params.symbol
SAMPLE TRADING PREIOD
"tradingPeriods": { "pre": [ [ { "timezone": "IST", "start": "2024-04-03T03:45:00.000Z", "end": "2024-04-03T03:45:00.000Z", "gmtoffset": 19800 } ] ], "post": [ [ { "timezone": "IST", "start": "2024-04-03T10:00:00.000Z", "end": "2024-04-03T10:00:00.000Z", "gmtoffset": 19800 } ] ], "regular": [ [ { "timezone": "IST", "start": "2024-04-03T03:45:00.000Z", "end": "2024-04-03T10:00:00.000Z", "gmtoffset": 19800 } ] ] }
In this trading periods date were correct but timestamp data is set to Jan 20
Timestamp data example