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

implement support for funds data #2041

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Conversation

ericpien
Copy link
Contributor

@ericpien ericpien commented Sep 1, 2024

Changes:

  • adding to scraper a new class FundsData.
  • Ticker can now reference the data via ticker.funds_data when appropriate. When the ticker symbol is not that of a fund's, the code will throw an error when a parameter of funds_data is called. i.e. yf.Ticker('AAPL').funds_data.description
  • Add unit tests in test_ticker.py for the funds data
  • minor change to test_ticker.py as YFChartError was removed from code in Prices: improve exceptions and logging #2000

Resolves:

Sample Code:

import yfinance as yf
spy_ticker = yf.Ticker('SPY')
spy_funds_data = spy_ticker.funds_data

spy_funds_data.description
spy_funds_data.fund_overview
spy_funds_data.fund_operations
spy_funds_data.asset_classes
spy_funds_data.top_holdings
spy_funds_data.equity_holdings
spy_funds_data.bond_holdings
spy_funds_data.bond_ratings
spy_funds_data.sector_weightings

Credits to #1784 for the idea

@ValueRaider
Copy link
Collaborator

Update readme

@ericpien
Copy link
Contributor Author

ericpien commented Sep 3, 2024

Update readme

Done. Thanks for reviewing.

@ValueRaider
Copy link
Collaborator

Set df indexes. And some might be better as simple dict.

@ericpien
Copy link
Contributor Author

ericpien commented Sep 3, 2024

Set df indexes. And some might be better as simple dict.

I converted data with just 2 columns to dicts and kept the others as DF with the indices set.

@ericpien
Copy link
Contributor Author

ericpien commented Sep 6, 2024

hey @ValueRaider not sure if you've been busy or just missed it so pinging again. thanks.

@ValueRaider
Copy link
Collaborator

Looks good for SPY. I'm just thinking about the exception experience.

I would rephrase this:

raise YFDataException("Failed to parse quote type. No Fund data found.")
to
raise YFDataException("No Fund data found.")

Then with:

        except IndexError:
            raise YFDataException("Failed to parse fund json data.")

don't discard the original exception. See how base.py handles exceptions.

- 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
@ericpien
Copy link
Contributor Author

ericpien commented Sep 7, 2024

Thanks for reviewing @ValueRaider. I interpreted the part about "don't discard the original exception" as meaning to log the base exception so implemented as such.

@ValueRaider ValueRaider merged commit 6b7a511 into ranaroussi:dev Sep 8, 2024
1 check passed
@ValueRaider ValueRaider mentioned this pull request Sep 29, 2024
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.

2 participants