Don't fix_Yahoo_returning_prepost_unrequested on Indian exhanges and 30m interval
Addresses #1436.
@ValueRaider, the only problem I have is that fix_Yahoo_returning_prepost_unrequested won't be run for 15m intervals either, because we Ticker.history() overwrites the user-specified interval of 30m with 15m.
the order of
fix_Yahoo_returning_prepost_unrequestedand downsampling doesn't matter in this case, as trading start date is 9:15 but the downsampling interval is30m.
I don't understand, please elaborate.
For 30m interval (15m, actually), the timestamps in the data just after fetching by requests look like this: 8:45, 9:00, 9:15, 9:30, 9:45, 10:00 ...
Now, the exchange start time is 9:15.
If you downsample first, you get 9:00, 9:30, 10:00, ..., then fix_Yahoo_returning_prepost_unrequested will remove 9:00.
If you fix_Yahoo_returning_prepost_unrequested first, you get 9:15, 9:30, 9:45, 10:00, ..., then downsampling removes 9:15.
In either case, 9:00 will be removed.
@ValueRaider, changed the interval check to the user-provided interval, instead of the interval passed to requests, so now fix_Yahoo_returning_prepost_unrequested will be skipped for NSI and BSE only for the true 30m interval.
In either case, 9:00 will be removed.
Wrong. I am running code now, if I reorder then yfinance returns downsampled interval 09:00 -> 09:30.
You are right, that works! Pushed reordering.
Good, that fixes the first interval. But I'm still not convinced aligning to HH:00 is the right choice. You said:
Yahoo Finance's frontend returns HH:00 timestamps for some reason and yfinance should follow that behaviour.
This is a terrible reason - Yahoo is US-centric and doesn't trade, so their reason is overruled by an Indian trader. I don't trade intraday so don't know a good authority on this. @AbhishekSRaut
Tradingview for ^NSEI starts with 9:15. That's a good enough argument for me to shift the beginning of 30m data for NSE and BSE to HH:15.
agreed with @ValueRaider other factors, like regional trading practices, should be considered when deciding on the best approach.
Tradingview for ^NSEI starts with 9:15. That's a good enough argument for me to shift the beginning of 30m data for NSE and BSE to HH:15.
this officialy mention here. you can read:
Normal / Limited Physical Market Open: 09:15 hrs Normal / Limited Physical Market Close: 15:30 hrs
thanks @ivan23kor and @ValueRaider to understand this and decide to fix it.
@AbhishekSRaut do you want the intervals to be [9:15AM, 3:15PM] or [9:15AM, 3:30PM]?
@ValueRaider, I added [9:15AM, 3:15PM] for (NSI, BSE) and kept [9:30AM, 3:30PM] for other exchanges.
Where in the code does 3:15pm vs 3:30pm matter?
do you want the intervals to be [9:15AM, 3:15PM] or [9:15AM, 3:30PM]?
if you talking about starting time of each candle, then its surely starts from 9:15 AM, and last is 3:15PM 3:30 PM is closing time i.e. the "last candle" which starts at 3:15 PM, will end at 3:30 PM.