From 0789b690a4160ad2fe77e42dbb181e8cacab9ab2 Mon Sep 17 00:00:00 2001 From: Lukas Vojt Date: Mon, 26 Jun 2023 16:50:02 +0200 Subject: [PATCH] fix: start year on history timestamp of 1900 is older than 100 years, so yahoo responds with error: GDEVW: 1d data not available for startTime=-2208994789 and endTime=1687780922. Only 100 years worth of day granularity data are allowed to be fetched per request. this should fix it, something similar was proposed here: https://github.com/ranaroussi/yfinance/pull/648 # Please enter the commit message for your changes. Lines starting --- .gitignore | 1 + yfinance/base.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5c73cbf..a0c363e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist yfinance.egg-info *.pyc .coverage +.idea/ .vscode/ build/ *.html diff --git a/yfinance/base.py b/yfinance/base.py index a114a42..f251665 100644 --- a/yfinance/base.py +++ b/yfinance/base.py @@ -170,8 +170,8 @@ class TickerBase: if interval == "1m": start = end - 604800 # Subtract 7 days else: - _UNIX_TIMESTAMP_1900 = -2208994789 - start = _UNIX_TIMESTAMP_1900 + max_start_datetime = pd.Timestamp.utcnow().floor("D") - _datetime.timedelta(days=99 * 365) + start = int(max_start_datetime.timestamp()) else: start = utils._parse_user_dt(start, tz) params = {"period1": start, "period2": end}