Created
May 7, 2016 18:51
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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