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

Closed

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

ValueRaider and others added 21 commits August 21, 2024 21:11
The new dividend repair logic looks for too big/small dividends/adjusts.
Because it analyses prices, it needs prices to be consistent - this means
for some exchanges, prices are converted to major currency e.g. pence -> £.
These exchanges are: .L, .TA, .JO
Also, multiday intervals are created by resampling adjusted 1d intervals.

Related change:
- _fix_prices_sudden_change() now fixes dividends with prices

Other repair fixes:
- add basic repair function to fix_Yahoo_returning_live_separate() to handle simple 100x price errors within same week/month
- fix _fix_prices_sudden_change() false positive on real massive price drop (clue = massive volume spike)
- price reconstruct fixes:
  - calibration: stop NaNs breaking, and detect currency unit mixup
  - fix a Pandas warning
Fix detecting div_adj_exceeds_prices.
Fine-tune fixing div_too_big.
Unit tests.
…ir-div-adjust

New: repair bad dividends and div-adjusts. Plus other repair fixes.
…urrency-bug

Fix price-repair-currency, logic was inverted
- adding to scraper a new class FundsData.
- Ticker can now reference the data via ticker.funds_data when appropriate.
- Add unit tests in test_ticker.py for the funds data
implement support for funds data
ValueRaider and others added 17 commits September 21, 2024 11:56
Sector and Industry class to query the data available on: https://finance.yahoo.com/sectors/:
- sector / industry overview
- sector / industry top companies
- sector / industry research reports
- sector top ETFs
- sector top Mutual Funds
- industries within sector
- industry's sector
- industry's top performing companies
- industry's top growth companies
Feature Proposal: Support Sector and Industry data from Markets Tab
Improve dividend repair:
- detect wrong date
- detect split missing from coincident dividend
- improve detecting adjust contradicting price action
- improve detecting when Close has adjustment
  (remove phantoms before, then use AdjClose -> AdjLow deltas)

Stop negative 'Adj Close' triggering a 'sudden change' repair.
fix keyerror with single element list passed to Tickers
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.

6 participants