-
Notifications
You must be signed in to change notification settings - Fork 679
Correct Yahoo period end timestamp calculation #365
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
Conversation
pandas_datareader/yahoo/daily.py
Outdated
@@ -97,7 +98,9 @@ def yurl(symbol): | |||
|
|||
def _get_params(self, symbol): | |||
unix_start = int(time.mktime(self.start.timetuple())) | |||
unix_end = int(time.mktime(self.end.timetuple())) | |||
day_end = self.end + datetime.timedelta(days=1) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to assume self.end is a whole day only with time 0:00:00?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a datetime created from year/month/day (as discussed in #356 there still might be some timezone issues ...)
The yahoo API becoming very sensitive ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need any additional tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is not correct.
import pandas_datareader as pdr
r = pdr.yahoo.daily.YahooDailyReader(['IBM'],'1/1/1960','1/1/2017 12:30:00')
r.end
Out[6]: Timestamp('2017-01-01 12:30:00')
Since it accepts times as well as dates you will need to create a new timestamp using the year, day and month and setting the hour to 23, minute to 59, and second to 59.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a test like this, to assert the end-points of the received data are correct (should fail before and pass after this PR)
import pandas_datareader as pdr
r = pdr.yahoo.daily.YahooDailyReader(['IBM'],'1/1/1960','1/1/2017 12:30:00')
r.end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback As discussed above, the failure was intermittent, sometimes not returning the data for 12/31. I'M m not sure what value a test on r.end
adds ... Thanks
Signed-off-by: Gábor Lipták <[email protected]>
@jreback Green after updates |
thanks @gliptak |
Signed-off-by: Gábor Lipták [email protected]
xref #356