Last week I wrote a small Python module for retrieving stock prices.
It used screen scraping to get data from Google Finance. Yahoo offers stock data in a much more digestible form which allowed me to get values without screen scraping and regular expressions. So, I wrote a module based around this.
This new module is much more comprehensive and exposes a Python API for retrieving all sorts of stock data from Yahoo Finance.
My ystockquote module provides a Python API for retrieving stock data from Yahoo Finance. This module contains the following functions:
Sample Usage:
>>> import ystockquote >>> print ystockquote.get_price('GOOG') 529.46 >>> print ystockquote.get_all('MSFT') {'stock_exchange': '"NasdaqNM"', 'market_cap': '268.6B', '200day_moving_avg': '29.2879', '52_week_high': '31.84', 'price_earnings_growth_ratio': '1.45', 'price_sales_ratio': '5.33', 'price': '28.65', 'earnings_per_share': '1.423', '50day_moving_avg': '28.7981', 'avg_daily_volume': '55579700', 'volume': '25330856', '52_week_low': '26.48', 'short_ratio': '1.60', 'price_earnings_ratio': '28.65', 'dividend_yield': '1.38', 'dividend_per_share': '0.40', 'price_book_ratio': '8.76', 'ebitda': '20.441B', 'change': '-0.39', 'book_value': '3.315'}
The module is available here: http://www.goldb.org/ystockquote.html
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.