You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using yfinance for a few years now with the same syntax. However, the last updates changed the API.
Thus I wonder if download(period=X) is intentionally changed not to accept user defined period as it used to be and forcing to pre-defined "Valid periods"?
The orig. syntax
→ yf.download('^SPX', period='30d', interval='1h', ignore_tz = True, progress=False)
the orig. syntax produces error such as:
→ ...Period 'Xd' is invalid, must be one of ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']")
The fix is to use start-end params. That is not a hard thing to do, but I think → shouldn't the yf API keep its behavior and compute start internally, whereas the end param = int(_time.time()), when the user sets a custom period rather than throwing an error?
Simple code that reproduces your problem
import yfinance as yf
# worked for several years
yf.download('^SPX', period='30d', interval='1h', ignore_tz = True, progress=False)
# leads to: ...Period '30d' is invalid, must be one of ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']")
# newly forced to use start-end instead
# yf.download('^SPX', start = X, interval='1h', ignore_tz = True, progress=False)
Debug log
The bug is given by new syntax forcing user to use start-end instead of custom period.
Bad data proof
No response
yfinance version
0.2.40
Python version
3.12.4
Operating system
Win11
The text was updated successfully, but these errors were encountered:
Thanks, I am aware of independent dev of yfinance and appreciate it very much.
I've started observing the behavior (not accepting custom period anymore) a month ago.
As the fix in this case is truly trivial - to compute internally start param for a custom (not supported) period - I was thinking it's worth nothing to share the observation, rahter than just silently fix my pipeline.
Describe bug
I've been using yfinance for a few years now with the same syntax. However, the last updates changed the API.
Thus I wonder if download(period=X) is intentionally changed not to accept user defined period as it used to be and forcing to pre-defined "Valid periods"?
The orig. syntax
→ yf.download('^SPX', period='30d', interval='1h', ignore_tz = True, progress=False)
the orig. syntax produces error such as:
→ ...Period 'Xd' is invalid, must be one of ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']")
The fix is to use start-end params. That is not a hard thing to do, but I think → shouldn't the yf API keep its behavior and compute start internally, whereas the end param = int(_time.time()), when the user sets a custom period rather than throwing an error?
Simple code that reproduces your problem
Debug log
The bug is given by new syntax forcing user to use start-end instead of custom period.
Bad data proof
No response
yfinance
version0.2.40
Python version
3.12.4
Operating system
Win11
The text was updated successfully, but these errors were encountered: