previous_close not working on some stock symbols
not working stock icon `import yfinance as yf
ticker = yf.Ticker('SOKE.IS').fast_info previous_close = ticker['previous_close']
print(previous_close)`
working stock icon `import yfinance as yf
ticker = yf.Ticker('MAVI.IS').fast_info previous_close = ticker['previous_close']
print(previous_close)`
traceback:
Traceback (most recent call last): File "D:\Python\PyCharm\yfinancetesting\main.py", line 4, in <module> previous_close = ticker['previous_close'] ~~~~~~^^^^^^^^^^^^^^^^^^ File "D:\Python\PyCharm\yfinancetesting\venv\Lib\site-packages\yfinance\base.py", line 110, in __getitem__ return getattr(self, k) ^^^^^^^^^^^^^^^^ File "D:\Python\PyCharm\yfinancetesting\venv\Lib\site-packages\yfinance\base.py", line 247, in previous_close self._prev_close = float(prices["Close"].iloc[-2]) ~~~~~~~~~~~~~~~~~~~~^^^^ File "D:\Python\PyCharm\yfinancetesting\venv\Lib\site-packages\pandas\core\indexing.py", line 1073, in __getitem__ return self._getitem_axis(maybe_callable, axis=axis) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\PyCharm\yfinancetesting\venv\Lib\site-packages\pandas\core\indexing.py", line 1625, in _getitem_axis self._validate_integer(key, axis) File "D:\Python\PyCharm\yfinancetesting\venv\Lib\site-packages\pandas\core\indexing.py", line 1557, in _validate_integer raise IndexError("single positional indexer is out-of-bounds") IndexError: single positional indexer is out-of-bounds
yfinanceversion = 0.2.9- Python version = 3.11.1
- Windows 11
Interesting ticker. Yahoo normally calculates "previous close" as before last trading day, but Yahoo only has trading data for today. What do you think the previous close should be?
Previous close is wrong for majority of data.
For example: adidas AG (ADS.DE) On summary tab Previous Close is 148.30 fast_info.previous_close returns 145.28
Data on historical data are not the same as data on summary tab.
Interesting ticker. Yahoo normally calculates "previous close" as before last trading day, but Yahoo only has trading data for today. What do you think the previous close should be?
I just wanted to pull the previous closing info.
OK I got solutions:
'SOKE.IS'
Fall back to accessing info. No other way to access it.
'ADS.DE'
That previous close is in post-market, and Yahoo wasn't returning in a interval="1d" prepost=True fetch (some exchanges they do). A interval="1h" prepost=True fetch returns correct close.
Can close? @ValueRaider
Not yet, want confirmation is fixed.
A fix is available is PIP pre-release and dev branch.
Ticker.info is fixed and fast_info deprecated in latest release