Closed adityanparikh closed 1 year ago
I'll handle this.
Can you try Git branch fix/events-merging
? Instructions in #1080
Thank for the quick turnaround, I was able to get the proper response using this branch.
Just FYI, could be unrelated but started seeing a different exception with a different line of code from this fix/events-merging
branch. I went back and checked into the main
branch and the said exception is not thrown with the same line of code.
print(yf.Ticker("BAOS").history(period="50wk",interval="1wk"))
Traceback (most recent call last): File "c:\Users\Documents\stock-screener\test.py", line 3, in
print(yf.Ticker("BAOS").history(period="50wk",interval="1wk")) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\yfinance\base.py", line 394, in history df = utils.safe_merge_dfs(df, splits, interval) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\yfinance\utils.py", line 587, in safe_merge_dfs td = _interval_to_timedelta(interval) File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\yfinance\utils.py", line 356, in _interval_to_timedelta return _pd.Timedelta(days=7, unit='d') File "pandas_libs\tslibs\timedeltas.pyx", line 1350, in pandas._libs.tslibs.timedeltas.Timedelta.new TypeError: Invalid datetime unit in metadata string "[d]"
It is unrelated, and odd only you get that error. What is pandas
version?
You might be able to fix by deleting part , unit='d'
, it's not necessary.
That's odd. But as per your suggestion deleting , unit='d'
from \site-packages\yfinance\utils.py seems to have fixed it for me. Thanks again.
Leave issue open until fixed by an official PIP release.
Also feel free to patch that timedelta
bug with a pull request.
I'm trying to build a screener and everything works fine for most tickers. But for certain few tickers I get the below exception. I checked the Yahoo finance website and the data is all there for those tickers that are returning the exception. It seems to work fine when I change either the period or interval.
Working Examples
print(yf.Ticker("F").history(period="49mo",interval="1mo"))
print(yf.Ticker("F").history(period="51mo",interval="1mo"))
print(yf.Ticker("F").history(period="50mo",interval="3mo"))
Returning Exception
print(yf.Ticker("F").history(period="50mo",interval="1mo"))
Exception