Requirements
- ystockquote
- pandas
Here is the sample python code, which will retrieve historical data from yahoo on any financial instrument (e.g. Google).
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
import pandas as pd | |
from pandas import Series, DataFrame | |
import ystockquote | |
his1 = ystockquote.get_historical_prices('GOOG', '2013-01-01', '2014-01-01') | |
stock1 = DataFrame(his1) | |
print stock1 | |
##if you just want e.g. the closing price | |
close_s1 = stock1.ix['Close'] | |
print close_s1 |
No comments:
Post a Comment