yfinance
yfinance copied to clipboard
download and history methods fail with proxy
Description yFinance.dowload() and Ticker.history() methods do not work with proxy and return no data with a message like: 1 Failed download:
- AMZN: No data found for this range, symbol may be delisted
yFinance: 0.2.9 + hotfix/proxy (base.py and fundamentals.py) python: 3.9.12 OS: Windows 10 20H2
Analysis Bug is in base.py module in function history() at line 571: data = get_fn( url=url, params=params, timeout=timeout )
Fix To fix it simply add proxy=proxy as a fourth parameter.
Enjoy!! MV
We have a fix but waiting for someone to test, can you? It's broken in other places too. Git branch hotfix/proxy
, instructions in #1080
Just use it normally and confirm/deny issue fixed. proxy is tricky to test because I don't have one. Try fetching history and some fundamental data like Ticker.cashflow
Hotfix works for history() and download() methods. 👍 Unfortunately it does not work for fundamentals. 👎 Example
symbol = yf.Ticker(ticker)
print("Shares:", symbol.shares)
gives a connection timeout error when creating the conn which suggests that the proxy has not taken into consideration by the Ticker object.
Given what we discussed and fixed in #1387 one way to fix this issue is the following:
- proxy should be passed also to Ticker object at init time as an optional param and stored in self
- (might also need to) modify all property functions of Ticker class like:
get_shares(proxy=self.proxy)
From my tests above code worked well for every fundamentals property with the exception of: market_cap (not sure whether was already implemented at hotfix time) and isin (which is still experimental).
Let me know when I can test. If tests will be ok then we can close both issues.