May 29, 2008

Python - Yahoo Stock Quotes - Historical Pricing

I recently received a patch to my ystockquote.py module for retrieving historical stock prices. It takes a start and end date (YYYMMDD) and a ticker symbol, and returns pricing data (a nested list) for the time period specified. For example:
import ystockquote

ticker = 'GOOG'
start = '20080520'
end = '20080523'

data = ystockquote.get_historical_prices(ticker, start, end)

for dat in data:
    print dat
Output:
['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Clos']
['2008-05-23', '546.96', '553.00', '537.81', '544.62', '4431500', '544.6']
['2008-05-22', '551.95', '554.21', '540.25', '549.46', '5076300', '549.4']
['2008-05-21', '578.52', '581.41', '547.89', '549.99', '6468100', '549.9']
['2008-05-20', '574.63', '582.48', '572.91', '578.60', '3313600', '578.6']
Post a Comment