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 testGetTicks(self): googleFinance = GoogleFinance() ret = googleFinance.getTicks('EBAY', start = '20110101', end = '20110110') print(ret)
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)
def testGetQuotes_badSymbol(self): googleFinance = GoogleFinance() self.assertRaises(UfException, googleFinance.getQuotes, *['AFSDFASDFASDFS', '20110101', '20110110'])
def testGetAll_badSymbol(self): googleFinance = GoogleFinance() self.assertRaises(UfException, googleFinance.getAll, 'fasfdsdfasf')
def testGetAll(self): googleFinance = GoogleFinance() data = googleFinance.getAll('EBAY') print(data) self.assertNotEqual(0, len(data))
def testGetQuotes(self): googleFinance = GoogleFinance() data = googleFinance.getQuotes('NASDAQ:EBAY', '20110101', '20110110') assert len(data)
def __init__(self): ''' constructor ''' super(GoogleDAM, self).__init__() self.__gf = GoogleFinance()
def testGetQuotes(self): googleFinance = GoogleFinance() data = googleFinance.getQuotes('NASDAQ:EBAY', '20131101', None) print[str(q) for q in data] assert len(data)