def download2(clearAll=False, download_latest=False, downloadHistory=False, parse_industry=False, stockList='stock_list_all'): logger.info('Begin Download stock list data {}'.format(stockList)) if clearAll: #clear redis cache # redclient.flushall() clear() #download securities list from local downloadQuoteList(True, False, stockList) quotes = findAllExistentTickers() import multiprocessing as mp pool = mp.Pool(len(quotes)) for code in quotes: s = Stock(code) pool.apply_async(download_stock, args=[ s, download_latest, settings.SINA, True, settings.CSV_ENGINE, False ]) pool.close() pool.join() logger.info('****Download latest price from sina finished****')
def download(clearAll=False, downloadLatest=False, downloadHistory=False, parse_industry=False, stockList='stock_list_all'): from stocktrace.parse.yahooparser import downloadHistoryData from stocktrace.dao.stockdao import clear, findAllExistentTickers from stocktrace.parse.reutersparser import downloadKeyStatDatas from stocktrace.parse.sinaparser import downloadLatestData from stocktrace.parse.ifengparser import parseIndustry from stocktrace.redis.redisservice import findStocksByList logger.info('***Start download finance data****') if clearAll: #clear redis cache # redclient.flushall() clear() #download industry info from ifeng if parse_industry: parseIndustry() #download securities list from local downloadQuoteList(True, False, stockList) #load stock list to redis zset loadStockListToRedis(stockList) #download statistics from reuters if settings.DOWNLOAD_KEY_STAT: downloadKeyStatDatas() quotes = findAllExistentTickers() #find from redis cache # quotes = findStocksByList(stockList) # quotes = stockList logger.debug(quotes) #update latest price from yahoo or sina #Seems YQL API is not stable,tables often to be locked if downloadLatest: downloadLatestData(quotes, engine=settings.SINA) if downloadHistory: #download history data from yahoo downloadHistoryData(quotes, engine=settings.CSV_ENGINE) logger.info('***Finish download finance data****')
def download(clearAll= False,downloadLatest = False,downloadHistory = False,parse_industry = False,stockList='stock_list_all'): from stocktrace.parse.yahooparser import downloadHistoryData from stocktrace.dao.stockdao import clear,findAllExistentTickers from stocktrace.parse.reutersparser import downloadKeyStatDatas from stocktrace.parse.sinaparser import downloadLatestData from stocktrace.parse.ifengparser import parseIndustry from stocktrace.redis.redisservice import findStocksByList logger.info('***Start download finance data****') if clearAll: #clear redis cache # redclient.flushall() clear(); #download industry info from ifeng if parse_industry: parseIndustry() #download securities list from local downloadQuoteList(True,False,stockList) #load stock list to redis zset loadStockListToRedis(stockList) #download statistics from reuters if settings.DOWNLOAD_KEY_STAT: downloadKeyStatDatas() quotes = findAllExistentTickers() #find from redis cache # quotes = findStocksByList(stockList) # quotes = stockList logger.debug(quotes) #update latest price from yahoo or sina #Seems YQL API is not stable,tables often to be locked if downloadLatest: downloadLatestData(quotes,engine = settings.SINA) if downloadHistory: #download history data from yahoo downloadHistoryData(quotes,engine = settings.CSV_ENGINE) logger.info('***Finish download finance data****')
def download2(clearAll= False,download_latest = False,downloadHistory = False,parse_industry = False,stockList='stock_list_all'): logger.info( 'Begin Download stock list data {}'.format(stockList)) if clearAll: #clear redis cache # redclient.flushall() clear(); #download securities list from local downloadQuoteList(True,False,stockList) quotes = findAllExistentTickers() import multiprocessing as mp pool = mp.Pool(len(quotes)) for code in quotes: s = Stock(code) pool.apply_async(download_stock, args = [s,download_latest, settings.SINA, True, settings.CSV_ENGINE, False]) pool.close() pool.join() logger.info( '****Download latest price from sina finished****')
def test_clear(self): from stocktrace.dao.stockdao import clear clear()