Open MichalRIcar opened 4 months ago
yfinance hasn't changed handling period: https://github.com/ranaroussi/yfinance/blob/0.1.55/yfinance/base.py
yfinance isn't affiliated with Yahoo
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.
30d period is still working with version 0.2.18, looks like an issue with newer versions of yfinance
It started with 0.2.32 when added cookie & crumb.
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