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

Cannot successfully retrieve data after 2022 in .download and .history. 1mo 3mo #1895

Open
nokemono opened this issue Mar 31, 2024 · 1 comment

Comments

@nokemono
Copy link

Describe bug

Cannot successfully retrieve data after 2022 in .download and .history.
'interval=1mo'
and
'interval=3mo'
do not seem to work correctly.

Simple code that reproduces your problem

import yfinance as yf

yf.enable_debug_mode()

stock_symbol = 'AAPL'

stock_data = yf.download(stock_symbol, period="max", interval='1mo', actions=True)

print(stock_data)

Debug log

DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
DEBUG Entering history()
DEBUG AAPL: Yahoo GET parameters: {'period1': '1925-04-24 19:00:00-05:00', 'period2': '2024-03-31 03:48:09-04:00', 'interval': '1mo', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/AAPL
DEBUG params={'period1': -1410220800, 'period2': 1711871289, 'interval': '1mo', '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 = 'C4zbuQbf2Zp'
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting get()
DEBUG AAPL: yfinance received OHLC data: 1985-01-01 05:00:00 -> 2024-03-28 20:00:00
DEBUG AAPL: OHLC after cleaning: 1985-01-01 00:00:00-05:00 -> 2024-03-01 00:00:00-05:00
DEBUG AAPL: OHLC after combining events: 1985-01-01 00:00:00-05:00 -> 2024-03-01 00:00:00-05:00
DEBUG AAPL: yfinance returning OHLC: 1985-01-01 00:00:00-05:00 -> 2024-03-01 00:00:00-05:00
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Exiting download()
Open High ... Dividends Stock Splits
Date ...
1985-01-01 0.520100 0.555814 ... 0.00 0.0
1985-02-01 0.511171 0.549114 ... 0.00 0.0
1985-03-01 0.444200 0.464285 ... 0.00 0.0
1985-04-01 0.386171 0.410714 ... 0.00 0.0
1985-05-01 0.372771 0.397328 ... 0.00 0.0
... ... ... ... ... ...
2023-05-01 NaN NaN ... 0.24 0.0
2023-08-01 NaN NaN ... 0.24 0.0
2023-11-01 NaN NaN ... 0.48 0.0
2024-02-01 NaN NaN ... 0.24 0.0
2024-03-01 171.699997 172.229996 ... 0.00 0.0

[454 rows x 8 columns]
Press any key to continue . . .

Bad data proof

No response

yfinance version

0.2.37

Python version

No response

Operating system

No response

@ItzXyers
Copy link

Try updating maybe?

Your code works on my machine (running yfinance==0.2.40).

My log:

DEBUG    Entering download()
DEBUG     Disabling multithreading because DEBUG logging enabled
DEBUG     Entering history()
DEBUG      Entering history()
DEBUG       AAPL: Yahoo GET parameters: {'period1': '1925-06-22 20:00:00-04:00', 'period2': '2024-05-29 14:52:45-04:00', 'interval': '1mo', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG       Entering get()
DEBUG        url=https://query2.finance.yahoo.com/v8/finance/chart/AAPL
DEBUG        params={'period1': -1405123200, 'period2': 1717008765, 'interval': '1mo', '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 = 'st20rwu6dJv'
DEBUG         Exiting _get_cookie_and_crumb_basic()
DEBUG        Exiting _get_cookie_and_crumb()
DEBUG        response code=200
DEBUG       Exiting get()
DEBUG       AAPL: yfinance received OHLC data: 1985-01-01 05:00:00 -> 2024-05-29 18:52:43
DEBUG       AAPL: OHLC after cleaning: 1985-01-01 00:00:00-05:00 -> 2024-05-01 00:00:00-04:00
DEBUG       AAPL: OHLC after combining events: 1985-01-01 00:00:00-05:00 -> 2024-05-01 00:00:00-04:00
DEBUG       AAPL: yfinance returning OHLC: 1985-01-01 00:00:00-05:00 -> 2024-05-01 00:00:00-04:00
DEBUG      Exiting history()
DEBUG     Exiting history()
DEBUG    Exiting download()

                  Open        High  ...  Dividends  Stock Splits
Date                                ...                         
1985-01-01    0.130022    0.138951  ...       0.00           0.0
1985-02-01    0.129464    0.137277  ...       0.00           0.0
1985-03-01    0.110491    0.116071  ...       0.00           0.0
1985-04-01    0.098772    0.102679  ...       0.00           0.0
1985-05-01    0.094866    0.099330  ...       0.00           0.0
...                ...         ...  ...        ...           ...
2024-01-01  187.149994  196.380005  ...       0.00           0.0
2024-02-01  183.990005  191.050003  ...       0.24           0.0
2024-03-01  179.550003  180.529999  ...       0.00           0.0
2024-04-01  171.190002  178.360001  ...       0.00           0.0
2024-05-01  169.580002  193.000000  ...       0.25           0.0

[473 rows x 8 columns]

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