#🔒 Help Needed with Incomplete 1-Minute Historical Data Fetching

4 messages · Page 1 of 1 (latest)

lofty sedge
#

Hi everyone,

I'm working with my broker's historical data API to retrieve a year's worth of 1-minute data for Indian stocks. The API documentation states that I should be able to fetch 30 days' worth of 1-minute data per request, but it only returns the last 2,000 records. I have attempted to contact their support team regarding this issue, but it's been over a week, and I haven't received a reply.

Thus, I've implemented a method that iteratively fetches 2,000 records per request by moving backward from the current date, aiming to accumulate a year's worth of data. This should total exactly 92,250 records. However, my script is only able to fetch 92,000 records. Here are the last few lines of the output:

...
Fetched 2000 records starting at 2023-09-04 10:55:00 and ending at 2023-09-11 12:59:00
Fetched 2000 records starting at 2023-08-25 15:05:00 and ending at 2023-09-04 10:54:00
Fetched 2000 records starting at 2023-08-18 13:00:00 and ending at 2023-08-25 15:04:00
Fetched 2000 records starting at 2023-08-10 10:55:00 and ending at 2023-08-18 12:59:00
Total fetched records: 92000

As you can see, the last request ends at 12:59, whereas the Indian stock market stays open from 9:15 AM to 3:30 PM. I believe that this timing discrepancy might be causing the data to fall short by 250 records.

Could anyone suggest a way to make my script keep fetching data until the market closes while not exceeding the 2,000 records per request limit?

Here’s my script(note: it requires API credentials, so it won't run without them):

https://paste.pythondiscord.com/NNZA

thin frigateBOT
#

@lofty sedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

thin frigateBOT
#

@lofty sedge

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.