def multiStockAll(codes): """ function takes a list of codes and provides information via pyql """ log.info("mining list [ %s ] for all information via pyql" % " : ".join(codes)) return pyql.lookup(codes)
def getDailyData(): # list of lists each list contains codes companyCodesPerIndustry = getCompanyCodes() for companies in companyCodesPerIndustry: companyDataList = pyql.lookup(companies) try: for companyData in companyDataList: insertData(companyData) except: log.error("no compainies in %s" % str(companies))
def web_scraper(): em_data = pos_query() symbol = [] em_vol = [] for k in em_data: new_d = dict(k) symbol.append(new_d['Symbol']) em_vol.append(new_d['EM_Volume']) sym_vol = [int(item['Volume']) for item in pyql.lookup(symbol[:400]) if item['Volume'] is not None] mkt_shr = [round(x / y * 100, 2) for x, y in zip(em_vol[:400], sym_vol) if x is not 0 or y is not 0] avg_vol = [str(item['AverageDailyVolume']) for item in pyql.lookup(symbol[:400])] em_vol = [vol for vol in em_vol] ms = map(float, mkt_shr) data = {'Symbol': symbol, 'Avg_Volume(3m)': avg_vol, 'Volume': sym_vol, 'EM_Volume': em_vol, 'Market_Share': ms} headings = ['Symbol', 'Avg_Volume(3m)', 'Volume', 'EM_Volume', 'Market_Share'] columns = [data[heading] for heading in headings] max_len = len(max(columns, key=len)) for col in columns: col += [None] * (max_len - len(col)) rows = [[col[i] for col in columns] for i in range(max_len)] data1 = dict(rows=rows, headings=headings) print data1 return data1
import pyql import ystockquote print('Using pyql') print('----------------------------------') #list = ['FFIV', 'MSFT', 'GOOG'] #print pyql.lookup(list) list = ['GOOG'] json = pyql.lookup(list) print json print('Using ystockquote') print('----------------------------------') print ystockquote.get_all('GOOG')