Profile
Pastes: 75268
Members: 1467

Paste

Plain view | Edit code: here. | Add this to your website. | Report abuse.

Short URL: N/A

Pasted as Python by eGlyph on Tuesday, April 6th, 2010 10:47pm ( 4 years ago )

  1. import urllib
  2.  
  3. class YStockQuote(object):
  4.     __fields = ['price', 'change', 'volume', 'avg_daily_volume', 'stock_exchange',
  5.               'market_cap', 'book_value', 'ebitda', 'dividend_per_share',
  6.               'dividend_yield', 'earnings_per_share', '52_week_high',      
  7.               '52_week_low', '50day_moving_avg', '200day_moving_avg', 'price_earnings_ratio',
  8.               'price_earnings_growth_ratio', 'price_sales_ratio', 'price_book_ratio', 'short_ratio']
  9.  
  10.     def __init__ (self, symbol):
  11.         uri  = 'http://finance.yahoo.com/d/quotes.csv?s=%s&f=%s' % (symbol, 'l1c1va2xj1b4j4dyekjm3m4rr5p5p6s7')
  12.         data = urllib.urlopen(uri).read().strip(' "').split(',')
  13.         self.__dict__ = dict([(f, data[n]) for n, f in enumerate(self.__fields)])
  14.  

Revise this Paste
Child(s): 17107
Your Name:
Code Language:
 
Security Image:
Text seen in Image:
Comments

Nothing has been added as yet. Post a comment.