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

'unit' keyword in TimedeltaIndex construction #1993

Closed andy60 closed 4 months ago

andy60 commented 4 months ago

Describe bug

When i run my code i have the following info: /Users/andreabertini/anaconda3/lib/python3.11/site-packages/yfinance/utils.py:782: FutureWarning: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead. df.index += _pd.TimedeltaIndex(dst_error_hours, 'h')

Simple code that reproduces your problem

for symbol_info in symbols:

for index, symbol_info in symbols.iterrows(): stock = symbol_info['titolo'] symbol = symbol_info['ticker'] data = yf.download(symbol, period="1y",progress=False) lastdate = data.index[-1] startdate = lastdate - pd.DateOffset(days=7) last_open=data["Open"].iloc[-1] last_high=data["High"].iloc[-1] last_low=data["Low"].iloc[-1] last_closing_price = data["Close"].iloc[-1] last_volume = data["Volume"].iloc[-1] prev_closing_price = data["Close"].iloc[-2] price_change_percent = ((last_closing_price - prev_closing_price) / prev_closing_price) * 100 sma_200 = ta.sma(data["Close"], length=200) sma_50 = ta.sma(data["Close"], length=50) sma_16 = ta.sma(data["Close"], length=16) sma_16_slope = sma_16.diff()

Debug log

When i run my code i have the following info: /Users/andreabertini/anaconda3/lib/python3.11/site-packages/yfinance/utils.py:782: FutureWarning: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead. df.index += _pd.TimedeltaIndex(dst_error_hours, 'h')

Bad data proof

No response

yfinance version

0.2.33

Python version

3.11.5

Operating system

Mac

ValueRaider commented 4 months ago

Update yfinance