Пример #1
0
    def __getSaveOneStockQuotes(self, stock, start, end):
        ''' get and save data for one symbol '''
        lastExcp = None
        failCount = 0
        quotes = None
        #try several times since it may fail
        while failCount < MAX_TRY:
            try:
                quotes = self.yahooDAM.readQuotes(stock.symbol, start, end)
            except BaseException as excp:
                failCount += 1
                lastExcp = excp
                if isinstance(excp, UfException) and excp.getCode() == Errors.NETWORK_404_ERROR:
                    raise BaseException("Failed, stock %s not found" % stock.symbol)
                else:
                    logger.warning("Failed, %s" % (excp))
                logger.info("Retry in 1 second")
                time.sleep(1)
            else:
                break

            if failCount >= MAX_TRY:
                raise BaseException("Can't retrieve historical data %s" % lastExcp)
        return quotes
Пример #2
0
 def poll(self, timeout = None):
     for t in self.threads:
         t.join(timeout) # no need to block, because thread should complete at last
         if t.is_alive():
             logger.warning("Thread %s timeout" %t.name)
     self.sqlDAM.commit()
Пример #3
0
def add(items: List[float]):
    if (a := items[0]) < 1:
        logger.warning("Oh no! {} < 1", a)