def _prices(cls, local_dir, ticker,dud) : filename = '{}/{}.pkl'.format(local_dir,ticker) reader = EXTRACT.instance().reader prices = reader.extract_from_yahoo(ticker) if prices is None : dud.append(ticker) return dud STOCK_TIMESERIES.save(filename, ticker, prices) return dud
def save(cls, local_dir, ticker, dud=None): if dud is None: dud = [] data = cls.read(ticker) if data is None: dud.append(ticker) return dud filename = '{}/{}.pkl'.format(local_dir, ticker) STOCK_TIMESERIES.save(filename, ticker, data) return dud
def save(cls, local_dir, ticker, dud): filename = '{}/{}.pkl'.format(local_dir, ticker) if cls.reader is None: cls.reader = STOCK_TIMESERIES.init() prices = cls.reader.extract_from_yahoo(ticker) if prices is None: dud.append(ticker) return dud STOCK_TIMESERIES.save(filename, ticker, prices) return dud
def _prices(cls, wait_on_failure, local_dir, ticker, dud): if dud is None: dud = [] filename = '{}/{}.pkl'.format(local_dir, ticker) reader = STOCK_TIMESERIES.init() prices = reader.extract_from_yahoo(ticker) if prices is None: dud.append(ticker) time.sleep(wait_on_failure) return dud STOCK_TIMESERIES.save(filename, ticker, prices) del prices return dud
def main(local, *stock_list): logging.info(stock_list) reader = STOCK_TIMESERIES.init() for stock in stock_list: filename = '{}/historical_prices/{}.pkl'.format(local, stock) ret = reader.extract_from_yahoo(stock) logging.debug(ret.tail(5)) STOCK_TIMESERIES.save(filename, stock, ret) if len(stock_list) > 0: return nasdaq = NASDAQ.init() for stock in nasdaq(): filename = '{}/historical_prices/{}.pkl'.format(local, stock) ret = reader.extract_from_yahoo(stock) STOCK_TIMESERIES.save(filename, stock, ret)