def request_price_data(self, cur, ticker): #price_data = self.get_db_price_data(cur, ticker) #if len(price_data) == 2: # print price_data # return try: price_data = web.DataReader(ticker, 'yahoo', self.start_date, self.end_date)['Adj Close'] except IOError: print 'YAHOO Data Access for {} Failed'.format(ticker) try: price_data = web.DataReader(ticker, 'google', self.start_date, self.end_date)['Close'] except IOError: print 'Google Data Access for {} Failed'.format(ticker) try: price_data = qp.get('WIKI', ticker, api_key=quandl_api_key, start_date=self.start_date, end_date=self.end_date)#['Adj. Close'] price_data.set_index('Date', inplace=True) price_data = price_data.loc[:,'Adj. Close'] if price_data.empty: return None except KeyError: print 'WIKI Data Access for {} Failed'.format(ticker) return return price_data
def request_price_data(self, cur, ticker): #price_data = self.get_db_price_data(cur, ticker) #if len(price_data) == 2: # print price_data # return try: price_data = web.DataReader(ticker, 'yahoo', self.start_date, self.end_date)['Adj Close'] except IOError: print 'YAHOO Data Access for {} Failed'.format(ticker) try: price_data = web.DataReader(ticker, 'google', self.start_date, self.end_date)['Close'] except IOError: print 'Google Data Access for {} Failed'.format(ticker) try: price_data = qp.get( 'WIKI', ticker, api_key=quandl_api_key, start_date=self.start_date, end_date=self.end_date) #['Adj. Close'] price_data.set_index('Date', inplace=True) price_data = price_data.loc[:, 'Adj. Close'] if price_data.empty: return None except KeyError: print 'WIKI Data Access for {} Failed'.format(ticker) return return price_data
def get_price_data(self, ticker, earnings_date): start_date = earnings_date - datetime.timedelta(days=5) end_date = earnings_date + datetime.timedelta(days=5) price_data = None try: price_data = web.DataReader(ticker, 'yahoo', start_date, end_date) except IOError: try: price_data = web.DataReader(ticker, 'google', start_date, end_date) except IOError: try: price_data = qp.get('WIKI', ticker, api_key=quandl_api_key, start_date = start_date, end_date = end_date) price_data.set_index('Date', inplace=True) except KeyError: pass return price_data
def getPricesFromExtern(self): prefix = adb.quandlPrefix[self.assetClass] dFrame = qp.get(self.assetAPI, prefix+self.code, start_date=self.sDate, end_date = self.eDate, api_key=keys.QUANDL_AUTH_KEY) return self.cleanDataFrame(dFrame)