Skip to content

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

Merged
merged 1 commit into from
Jul 10, 2017
Merged

Correct Yahoo period end timestamp calculation #365

merged 1 commit into from
Jul 10, 2017

Conversation

gliptak
Copy link
Contributor

@gliptak gliptak commented Jul 8, 2017

Signed-off-by: Gábor Lipták [email protected]

xref #356

@@ -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) \
Copy link
Contributor

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?

Copy link
Contributor Author

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 ...

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback I'm proposing this change, because I noted that existing Yahoo tests behaved differently locally vs on Travis. @bashtage also seem to have observed same. I see existing tests covering this change (although maybe somebody could reconfirm boundaries?)

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

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

Copy link
Contributor Author

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

@gliptak
Copy link
Contributor Author

gliptak commented Jul 9, 2017

@jreback Green after updates

@jreback jreback added this to the 0.5.0 milestone Jul 10, 2017
@jreback jreback merged commit 75e0376 into pydata:master Jul 10, 2017
@jreback
Copy link
Contributor

jreback commented Jul 10, 2017

thanks @gliptak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants