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

NaN on the last Close for some tickers if using Tickers function with more than one ticker #2177

Open
MarcoOvidi opened this issue Dec 13, 2024 · 2 comments

Comments

@MarcoOvidi
Copy link

Describe bug

If I call
tk = yfinance.Tickers('1ABBV.MI').history(start=start_date, end=end_date) the last Close for 1AABV.MI is always filled

If I Call
tk = yfinance.Tickers('1ABBV.MI 1AAPL.MI').history(start=start_date, end=end_date) I always get the last close as NaN for 1AABV.MI

if I try to swap '1AAPL.MI 1ABBV.MI ' is the same NaN Close for 1AABV.MI

At the end 1AABV.MI (and some others) have this strange behavior if called tighter with other Tickers.

Simple code that reproduces your problem

Works:
tk = yfinance.Tickers('1ABBV.MI').history(start=start_date, end=end_date)

Not Works:
tk = yfinance.Tickers('1ABBV.MI 1AAPL.MI').history(start=start_date, end=end_date)

Debug log

DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG 1AAPL.MI: Yahoo GET parameters: {'period1': '2016-09-26 00:00:00+02:00', 'period2': '2024-12-14 00:00:00+01:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/1AAPL.MI
DEBUG params={'period1': 1474840800, 'period2': 1734130800, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG loaded persistent cookie
DEBUG reusing cookie
DEBUG crumb = 'L4bxwRUg0Qo'
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG 1AAPL.MI: yfinance received OHLC data: 2017-10-26 07:00:00 -> 2024-12-13 14:59:05
DEBUG 1AAPL.MI: OHLC after cleaning: 2017-10-26 09:00:00+02:00 -> 2024-12-13 15:59:05+01:00
DEBUG 1AAPL.MI: OHLC after combining events: 2017-10-26 00:00:00+02:00 -> 2024-12-13 00:00:00+01:00
DEBUG 1AAPL.MI: yfinance returning OHLC: 2017-10-26 00:00:00+02:00 -> 2024-12-13 00:00:00+01:00
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Entering history()
DEBUG Entering history()
DEBUG 1ABBV.MI: Yahoo GET parameters: {'period1': '2016-09-26 00:00:00+02:00', 'period2': '2024-12-14 00:00:00+01:00', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/1ABBV.MI
DEBUG params={'period1': 1474840800, 'period2': 1734130800, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG 1ABBV.MI: yfinance received OHLC data: 2023-11-24 08:00:00 -> 2024-12-12 08:00:00
DEBUG 1ABBV.MI: OHLC after cleaning: 2023-11-24 09:00:00+01:00 -> 2024-12-12 09:00:00+01:00
DEBUG 1ABBV.MI: OHLC after combining events: 2023-11-24 00:00:00+01:00 -> 2024-12-12 00:00:00+01:00
DEBUG 1ABBV.MI: yfinance returning OHLC: 2023-11-24 00:00:00+01:00 -> 2024-12-12 00:00:00+01:00
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Exiting download()

Bad data proof

No response

yfinance version

yfinance==0.2.50

Python version

python 3.13.0

Operating system

Mac OS

@ValueRaider
Copy link
Collaborator

Yahoo returning different end dates:

DEBUG 1AAPL.MI: yfinance received OHLC data: 2017-10-26 07:00:00 -> 2024-12-13 14:59:05
DEBUG 1ABBV.MI: yfinance received OHLC data: 2023-11-24 08:00:00 -> 2024-12-12 08:00:00

I can't reproduce bug.

@MarcoOvidi
Copy link
Author

Ciao @ValueRaider what you mean ?

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

2 participants