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
pull/1576/head
Lukas Vojt 2023-06-26 16:50:02 +02:00
parent 1cb0b215c4
commit 0789b690a4
No known key found for this signature in database
GPG Key ID: 00F1C78104D62A7F
2 changed files with 3 additions and 2 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ dist
yfinance.egg-info
*.pyc
.coverage
.idea/
.vscode/
build/
*.html

View File

@ -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}