def __buildExl(self, stock, workbook): ''' get one stock historical data and store it ''' try: ws = workbook.add_sheet(stock) #get data yahooFinance = YahooFinance() allData = yahooFinance.getHistoricalPrices(stock, self.__startDate, self.__endDate) for col, field in enumerate( ['date', 'open', 'high', 'low', 'close', 'volume', 'adjClose']): ws.write(0, col, field) for row, data in enumerate(allData): for col, field in enumerate([ 'date', 'open', 'high', 'low', 'close', 'volume', 'adjClose' ]): ws.write(row + 1, col, getattr(data, field)) except UfException as excp: raise excp except Exception: raise UfException( Errors.UNKNOWN_ERROR, "historicalStorage.__buildExl got unknown error %s" % traceback.print_exc())
class HistoricalDataFeeder(BaseModule): ''' feeder that get stock data from Yahoo Finance ''' def __init__(self): ''' Constructor ''' super(HistoricalDataFeeder, self).__init__() self.__yahooFinance = YahooFinance() def execute(self, input): ''' preparing data''' super(HistoricalDataFeeder, self).execute(input) return {'history stock': self.__yahooFinance.getHistoricalPrices(input, '1990-01-01', date.today())}
class HistoricalDataFeeder(BaseModule): ''' feeder that get stock data from Yahoo Finance ''' def __init__(self): ''' Constructor ''' super(HistoricalDataFeeder, self).__init__() self.__yahooFinance = YahooFinance() def execute(self, input): ''' preparing data''' super(HistoricalDataFeeder, self).execute(input) return { 'history stock': self.__yahooFinance.getHistoricalPrices(input, '1990-01-01', date.today()) }
def __buildExl(self, stock, workbook): ''' get one stock historical data and store it ''' try: ws = workbook.add_sheet(stock) #get data yahooFinance = YahooFinance() allData = yahooFinance.getHistoricalPrices(stock, self.__startDate, self.__endDate) for col, field in enumerate(['date', 'open', 'high', 'low', 'close', 'volume', 'adjClose']): ws.write(0, col, field) for row, data in enumerate(allData): for col, field in enumerate(['date', 'open', 'high', 'low', 'close', 'volume', 'adjClose']): ws.write(row+1, col, getattr(data, field) ) except UfException as excp: raise excp except Exception: raise UfException(Errors.UNKNOWN_ERROR, "historicalStorage.__buildExl got unknown error %s" % traceback.print_exc())