Skip to content

Commit

Permalink
fix: start year on history
Browse files Browse the repository at this point in the 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:
ranaroussi#648

 # Please enter the commit message for
your changes. Lines starting
  • Loading branch information
lucas03 committed Jun 26, 2023
1 parent 1cb0b21 commit 0789b69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dist
yfinance.egg-info
*.pyc
.coverage
.idea/
.vscode/
build/
*.html
Expand Down
4 changes: 2 additions & 2 deletions yfinance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def history(self, period="1mo", interval="1d",
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}
Expand Down

0 comments on commit 0789b69

Please sign in to comment.