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

Patch keyError in #2027 #2029

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

aleksfasting
Copy link
Contributor

Solves ´KeyError´ occurrence in #2027.

Adds Try/Except statement to find keyerror and return to old code if the keyerror is triggered.

@ValueRaider
Copy link
Collaborator

That's not the solution. Look at the metadata.

@aleksfasting
Copy link
Contributor Author

aleksfasting commented Aug 20, 2024

The same information as in the original PR, #2026, can be fetched from the 'currentTradingPeriod' key in the metadata. The metadata from the code that triggered the KeyError,

dat = yf.Ticker('0001.HK')
dat.history(start=1719763200, end=1720540800, interval='30m', prepost=True)

will have the same format as most other stocks for this key.

I don't know if Yahoo Finance may give differently formated metadata for the ´'currentTradingPeriod'´ key.

@ValueRaider
Copy link
Collaborator

Just add 2 unit tests: one with prepost=False, other with True. Then rebase to dev branch #1084

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

Successfully merging this pull request may close these issues.

3 participants