Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

previous_close not working on some stock symbols #1381

Closed
FrknKAYA opened this issue Jan 30, 2023 · 7 comments
Closed

previous_close not working on some stock symbols #1381

FrknKAYA opened this issue Jan 30, 2023 · 7 comments

Comments

@FrknKAYA
Copy link

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

  • yfinance version = 0.2.9
  • Python version = 3.11.1
  • Windows 11
@ValueRaider
Copy link
Collaborator

ValueRaider commented Jan 30, 2023

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?

@playinlab
Copy link

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.

@FrknKAYA
Copy link
Author

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.

@ValueRaider
Copy link
Collaborator

ValueRaider commented Jan 30, 2023

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.

@asafravid
Copy link
Collaborator

Can close? @ValueRaider

@ValueRaider
Copy link
Collaborator

Not yet, want confirmation is fixed.

A fix is available is PIP pre-release and dev branch.

@ValueRaider
Copy link
Collaborator

Ticker.info is fixed and fast_info deprecated in latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants