@Arun86 The flow is impressive and I appreciate you sharing it with the community.
In a naive way, though you are waiting for the 5-minute candle close to handle the 10 sec fetch issue, I would rather start the fetch at the 51st second of the 4th minute, considering that the 9-second fetch will not have changes and even if it does, it will fall under the accuracy thresholds. This will make the system execute at an ATM with some accuracy thresholds at the 1st second after the 5-minute candle.
It depends on how you execute at 9:20. I assume you have a cron to run every 5 minutes(300 seconds) starting from 9:15. Get the data, store and accordingly execute. You need to change it to run every 51 seconds and then cap it to 5 minutes. Something like the following
It’s not about getting the 5-minute api call. It’s about executing the API when the cron is triggered to retrieve the prices at that instant, i.e., the current prices.
@Arun86 I am not sure how the rate limit causes an issue? If you are doing it for an Index, i.e Nifty and Bank Nifty, it’s just 2 calls per 290 seconds. If you are running it for stocks then you will need to batch it i.e so each batch’s 5-minute differs by 1 second each and each batch has 5 stocks. Are you running it for all FnO stocks at once?