Skip to content

Fix get_data_yahoo() Bug in windows when start date is earlier than 1970-1-1 8:00 #846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas_datareader/yahoo/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import re
import time
import datetime

from pandas import DataFrame, isnull, notnull, to_datetime

Expand Down Expand Up @@ -127,7 +128,8 @@ def url(self):
def _get_params(self, symbol):
# This needed because yahoo returns data shifted by 4 hours ago.
four_hours_in_seconds = 14400
unix_start = int(time.mktime(self.start.timetuple()))
unix_zero = datetime.datetime(1970, 1, 1, 8)
unix_start = int((self.start - unix_zero).total_seconds())
unix_start += four_hours_in_seconds
day_end = self.end.replace(hour=23, minute=59, second=59)
unix_end = int(time.mktime(day_end.timetuple()))
Expand Down
4 changes: 3 additions & 1 deletion pandas_datareader/yahoo/fx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import time
import datetime
import warnings

from pandas import DataFrame, Series, concat, to_datetime
Expand Down Expand Up @@ -39,7 +40,8 @@ class YahooFXReader(YahooDailyReader):
"""

def _get_params(self, symbol):
unix_start = int(time.mktime(self.start.timetuple()))
unix_zero = datetime.datetime(1970, 1, 1, 8)
unix_start = int((self.start - unix_zero).total_seconds())
day_end = self.end.replace(hour=23, minute=59, second=59)
unix_end = int(time.mktime(day_end.timetuple()))

Expand Down