def __init__(self): companies = list(data.get_companies()) self.companies = [c.symbol for c in companies] self.strategies = [ "magic_formula_ttm", "magic_formula_ftm", "garp_ratio" ]
def yahoo_roa(sleep_time): companies = list(data.get_companies()) companies = chunks(companies, BATCH) work = [] for c in companies: t = threading.Thread(target=get_yahoo_roa(c)) work.append(t) t.start()
def yahoo_finance(sleep_time): companies = list(data.get_companies()) companies = [companies[i:i+BATCH] for i in range(0, len(companies), BATCH)] for i, batch in enumerate(companies): if i > 0: time.sleep(sleep_time) batch = dict([(c.symbol, c) for c in batch]) url = 'https://query.yahooapis.com/v1/public/yql' params = { 'q': 'select * from yahoo.finance.quotes where symbol IN ("%s")' % '", "'.join(batch.keys()), 'format': 'json', 'env': 'http://datatables.org/alltables.env', } response = requests.get(url, params=params) body = response.json() LOGGER.info('Getting quotes: %s' % ', '.join(batch.keys())) for item in body['query']['results']['quote']: company = batch[item['symbol']] timestamp = get_time() data.set_financial_data( company=company, symbol=company.symbol, date=timestamp, ask=decode_money(item.get('Ask')), market_cap=decode_money(item.get('MarketCapitalization')), ebitda=decode_money(item.get('EBITDA')), pe_ratio_ttm=decode_float(item.get('PERatio')), peg_ratio=decode_float(item.get('PEGRatio')), DividendYield = decode_float(item.get('DividendYield')), OneyrTargetPrice = decode_float(item.get('OneyrTargetPrice')), EPSEstimateCurrentYear = decode_float(item.get('EPSEstimateCurrentYear')), EPSEstimateNextYear = decode_float(item.get('EPSEstimateNextYear')), EPSEstimateNextQuarter = decode_float(item.get('EPSEstimateNextQuarter')), )
from tabulate import tabulate import operator from alg import Alg import data companies = list(data.get_companies()) companies = [c.symbol for c in companies] data1 = Alg().getMagicFormulaTrailing() data2 = Alg().getMagicFormulaFuture() data3 = Alg().getGARP() #data2 = Alg().getCompany(['AAPL', 'SSTK', 'CRM', 'DATA', 'GRMN']) #data3 = Alg().getCompany(companies) print data4 #print tabulate(data4, headers="keys") #print tabulate(data1, headers="keys") #print tabulate(data2, headers="keys") #print tabulate(data3, headers="keys")