Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fix_Yahoo_returning_prepost_unrequested on Indian exhanges and 30m interval #1447

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ivan23kor
Copy link
Contributor

Addresses #1436.

@ivan23kor ivan23kor changed the title Don't fix_Yahoo_returning_prepost_unrequested on Indian exhanges and 15m interval Don't fix_Yahoo_returning_prepost_unrequested on Indian exhanges and 30m interval Mar 9, 2023
@ivan23kor
Copy link
Contributor Author

ivan23kor commented Mar 9, 2023

@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.

@ValueRaider
Copy link
Collaborator

the order of fix_Yahoo_returning_prepost_unrequested and downsampling doesn't matter in this case, as trading start date is 9:15 but the downsampling interval is 30m.

I don't understand, please elaborate.

@ivan23kor
Copy link
Contributor Author

ivan23kor commented Mar 9, 2023

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.

@ivan23kor
Copy link
Contributor Author

@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.

@ValueRaider
Copy link
Collaborator

ValueRaider commented Mar 9, 2023

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.

@ivan23kor
Copy link
Contributor Author

You are right, that works!
Pushed reordering.

@ValueRaider
Copy link
Collaborator

ValueRaider commented Mar 9, 2023

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

@ivan23kor
Copy link
Contributor Author

ivan23kor commented Mar 9, 2023

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.

@AbhishekSRaut
Copy link

AbhishekSRaut commented Mar 10, 2023

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.

@ivan23kor
Copy link
Contributor Author

@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.

@ValueRaider
Copy link
Collaborator

Where in the code does 3:15pm vs 3:30pm matter?

@AbhishekSRaut
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants