Profile
Pastes: 74278
Members: 1438

Paste

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

Short URL: N/A

Pasted as Python by eGlyph on Wednesday, April 7th, 2010 5:04am ( 4 years ago )

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

Revise this Paste
Parent: 17097
Your Name:
Code Language:
 
Security Image:
Text seen in Image:
Comments

Nothing has been added as yet. Post a comment.