Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devStepsize/e370113d0b50f3b10c86b7d5101e9cbf to your computer and use it in GitHub Desktop.
Save devStepsize/e370113d0b50f3b10c86b7d5101e9cbf to your computer and use it in GitHub Desktop.
Using the yahoo finance module (pip install it), get the historical price of a stock
from yahoo_finance import Share
def get_stock_price_history(share_code, start_date, end_date):
"""
start_date/end_date are of format: YYYY-MM-DD
"""
stock = Share(share_code)
sopen = stock.get_open()
if not sopen:
print "Wrong stock code"
return
return stock.get_historical(start_date, end_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment