Skip to content
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

Fix For Obtaining Yahoo Historical Data #52

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

skillachie
Copy link

@skillachie skillachie commented Jun 12, 2017

Fix to update API to get historical data based on recent changes made by Yahoo. Inspired by fix in pandas_reader using cookies

@skillachie
Copy link
Author

Strange.

Not sure why the assert fails in the Travis environment. Can you take a look locally.

screen shot 2017-06-11 at 11 23 20 pm

@johnjackoleary
Copy link

Tested locally, and seems to work for me.

Copy link

@johnjackoleary johnjackoleary left a comment

Choose a reason for hiding this comment

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

lgtm

'cookie': cookies}


def get_historical_prices(symbol, start_date, end_date, interval='1d'):

Choose a reason for hiding this comment

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

I might be using this wrong, but can 'interval' only be a number of days? If so, maybe rename the variable to interval_days and have the input be an int? That will make it more clear how it's used.

Copy link
Author

@skillachie skillachie Jul 17, 2017

Choose a reason for hiding this comment

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

interval variable can take the following:

1d - https://finance.yahoo.com/quote/%5EGSPC/history?period1=1468731600&period2=1500267600&interval=1d&filter=history&frequency=1d

1mo - https://finance.yahoo.com/quote/%5EGSPC/history?period1=1468731600&period2=1500267600&interval=1mo&filter=history&frequency=1mo

1wk - https://finance.yahoo.com/quote/%5EGSPC/history?period1=1468731600&period2=1500267600&interval=1wk&filter=history&frequency=1wk

This determines if you would like to obtain data rolled up daily, weekly or monthly. Changing it to interval days might be misleading. However this library was used to obtain only daily data before so we could remove it as an argument.

What do you think?

Choose a reason for hiding this comment

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

Oh I see. Hmm... Either way seems fine. Maybe keep it because being able to request at a specific interval would be sweet :D although could you add a small docstring explaining the options?

Copy link
Author

Choose a reason for hiding this comment

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

No problem. Will add it and push the update. Any idea why Travis returns wrong assert?

Copy link
Author

Choose a reason for hiding this comment

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

Done with the requested changes

Copy link

@johnjackoleary johnjackoleary left a comment

Choose a reason for hiding this comment

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

Looks good. No clue on Travis... :/

except ImportError:
# py2
from urllib2 import Request, urlopen
from urllib import urlencode
import sys
reload(sys)
sys.setdefaultencoding('utf8')
Copy link

@nooperpudd nooperpudd Oct 10, 2017

Choose a reason for hiding this comment

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

please don't reload sys to change the default encoding

@cgoldberg
Copy link
Owner

hmm.. travis still failing. I'd like to get this merged.

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

Successfully merging this pull request may close these issues.

4 participants