Created
September 13, 2013 01:00
-
-
Save huangt/6545776 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ystockquote | |
import csv | |
#print ystockquote.get_price('GOOG') | |
#print ystockquote.get_all('MSFT') | |
#print ystockquote.get_book_value('GOOG') | |
csvfile = open('nasdaqlist.csv', 'rb') | |
reader = csv.reader(csvfile) | |
rownum = 0 | |
stocksymbols = [] | |
stockDetails =[] | |
for row in reader: | |
# Save header row. | |
if rownum == 0: | |
header = row | |
else: | |
#print row | |
stocksymbols.append(row[0]) | |
stockDetails.append(row) | |
rownum += 1 | |
csvfile.close() | |
results = [] | |
for stockDetail in stockDetails: | |
symbol = stockDetail[0] | |
price = float(ystockquote.get_price(symbol)) | |
bookvalue = float(ystockquote.get_book_value(symbol)) | |
halfBook = bookvalue * 0.5 | |
if (price <= halfBook): | |
print ', '.join(stockDetail) | |
results.append(symbol) | |
print len(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment