ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.89k stars 2.44k forks source link

mutual fund holders for few tickers not able to fetch data. #1980

Closed SphereSK closed 4 months ago

SphereSK commented 4 months ago

Describe bug

mutual fund holders are not getting data for tickers (not all of them)

python3 example/test.py Traceback (most recent call last): File "/env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 103, in _fetch_and_parse self._parse_insider_transactions(data["insiderTransactions"]) KeyError: 'insiderTransactions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/python_script/example/test.py", line 8, in actions = stock.get_mutualfund_holders() File "/env/lib/python3.10/site-packages/yfinance/base.py", line 191, in get_mutualfund_holders data = self._holders.mutualfund File "/env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 49, in mutualfund self._fetch_and_parse() File "env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 107, in _fetch_and_parse raise YFDataException("Failed to parse holders json data.") yfinance.exceptions.YFDataException: Failed to parse holders json data.

Simple code that reproduces your problem

import yfinance as yf

CREATE A TICKER INSTANCE PASSING TESLA AS THE TARGET COMPANY

ticker = "ARM" # stock = yf.Ticker(ticker)

CALL THE MULTIPLE FUNCTIONS AVAILABLE AND STORE THEM IN VARIABLES.

actions = stock.get_mutualfund_holders()

PRINT THE RESULTS

print(actions) print(''200)

Debug log

python3 example/test.py DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary//ARM DEBUG Entering get() DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary//ARM DEBUG params={'modules': 'institutionOwnership,fundOwnership,majorDirectHolders,majorHoldersBreakdown,insiderTransactions,insiderHolders,netSharePurchaseActivity', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG loaded persistent cookie DEBUG reusing cookie DEBUG crumb = 'NIJ2iVjflMh' DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=200 DEBUG Exiting get() Traceback (most recent call last): File "/env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 103, in _fetch_and_parse self._parse_insider_transactions(data["insiderTransactions"]) KeyError: 'insiderTransactions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/python_script/example/test.py", line 9, in actions = stock.get_mutualfund_holders() File "/env/lib/python3.10/site-packages/yfinance/base.py", line 191, in get_mutualfund_holders data = self._holders.mutualfund File "/env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 49, in mutualfund self._fetch_and_parse() File "/env/lib/python3.10/site-packages/yfinance/scrapers/holders.py", line 107, in _fetch_and_parse raise YFDataException("Failed to parse holders json data.") yfinance.exceptions.YFDataException: Failed to parse holders json data.

Bad data proof

No response

yfinance version

latest one

Python version

No response

Operating system

No response

ValueRaider commented 4 months ago

Duplicate #1893