class GoogleDAM(BaseDAM): ''' Google DAO ''' def __init__(self): ''' constructor ''' super(GoogleDAM, self).__init__() self.__gf = GoogleFinance() def readQuotes(self, start, end): ''' read quotes from google Financial''' if self.symbol is None: LOG.debug('Symbol is None') return [] return self.__gf.getQuotes(self.symbol, start, end) def readTicks(self, start, end): ''' read ticks from google Financial''' if self.symbol is None: LOG.debug('Symbol is None') return [] return self.__gf.getTicks(self.symbol, start, end) def readFundamental(self): ''' read fundamental ''' if self.symbol is None: LOG.debug('Symbol is None') return {} return self.__gf.getFinancials(self.symbol)
def getStockFinancials(self, writeOutput=False): ''' get stock financials ''' with open(self.__stockList) as inFile: stockFinancials = {} for stockName in inFile.readlines(): try: stockName = stockName.strip() googleFinance = GoogleFinance() financials = googleFinance.getFinancials(stockName) print "Processed %s" % stockName stockFinancials[stockName] = financials except StandardError as excp: print '%s' % excp if writeOutput: with open(self.__outputFile, 'w') as outFile: outFile.write(json.dumps(stockFinancials)) return stockFinancials return {}
def testGetFinancials(self): googleFinance = GoogleFinance() #ret = googleFinance.getFinancials('NASDAQ:EBAY', ['Net Income', 'Total Revenue', 'Diluted Normalized EPS', 'Total Common Shares Outstanding'], False) ret = googleFinance.getFinancials('NASDAQ:EBAY') print(ret)