def stopClient(self): try: if self.__connected: self.close() self.close_connection() except Exception, e: logger.warning("Failed to close connection")
def stopClient(self): try: if self.__connected: self.close() self.close_connection() except Exception as e: logger.warning("Failed to close connection: %s" % (e))
def __onResult(self, requestId, data): try: cb = self.__resultCB[requestId] self.__unregisterCallbacks(requestId) if cb: cb(data) except KeyError: logger.warning("Result for request %s: %s" % (requestId, data))
def process_symbol(writer, symbol): try: logger.info("Getting info for %s" % (symbol)) url = "http://finance.yahoo.com/q/in?s=%s+Industry" % (symbol) htmlTree = lxml.html.parse(url) company = find_company(htmlTree, symbol) if not company: raise Exception("Company name not found") sector = find_sector(htmlTree) if not sector: sector = "" logger.warning("Sector not found") industry = find_industry(htmlTree) if not industry: industry = "" logger.warning("Industry not found") writer.addStock(symbol, company, sector, industry) except Exception, e: logger.error(str(e))
def process_symbol(writer, symbol): try: logger.info("Getting info for %s" % (symbol)) url = "http://finance.yahoo.com/q/in?s=%s+Industry" % (symbol) htmlTree = lxml.html.parse(url) company = find_company(htmlTree, symbol) if not company: raise Exception("Company name not found") sector = find_sector(htmlTree) if not sector: sector = "" logger.warning("Sector not found") industry = find_industry(htmlTree) if not industry: industry = "" logger.warning("Industry not found") writer.addStock(symbol, company, sector, industry) except Exception as e: logger.error(str(e))
def __processGap(self, prevDateTime, currentDateTime): dates = self.getDatesInBetween(prevDateTime, currentDateTime) dates = [x for x in dates if not self.isTradingDay(x)] if len(dates) >= self.__threshold: logger.warning("%d day gap between %s and %s" % (len(dates), prevDateTime, currentDateTime))
def onUnknownOperation(self, operation, data): logger.warning("Unknown operation %s: %s" % (operation, data))
def __processGap(self, prevDateTime, currentDateTime): dates = self.getDatesInBetween(prevDateTime, currentDateTime) dates = filter(lambda x: not self.isTradingDay(x), dates) if len(dates) >= self.__threshold: logger.warning("%d day gap between %s and %s" % (len(dates), prevDateTime, currentDateTime))
def onUnknownEvent(self, event): logger.warning("Unknown event: %s" % (event))
def onUnknownEvent(self, event): logger.warning("Unknown event: %s." % event)