def processStrategy(stock): try: if const.REFRESH_DATA: dataloader.downloadStockData(stock) prices = dataloader.importData(4, stock['file']) const.currentSecId = stock['id'] tr = strategy.runStrategy(prices) return tr except: return None
prices = dataloader.importData(4, stock['file']) const.currentSecId = stock['id'] tr = strategy.runStrategy(prices) return tr except: return None #finalPool.estimate(tr) #q.put(tr) if __name__ == "__main__": rwlogging.clearLog() if const.SOURCE_TYPE < 3: prices = dataloader.importData(const.SOURCE_TYPE, const.DATA_FILE) strategy.runStrategy(prices) if const.SOURCE_TYPE == 3: stocks = dataloader.importStockList(const.LIST_FILE) for stock in stocks: dataloader.downloadStockData(stock) if const.SOURCE_TYPE == 4: stocks = dataloader.importStockList(const.LIST_FILE) finalPool = Pool(100) with concurrent.futures.ProcessPoolExecutor( max_workers=const.MAX_PROCESS_NUM) as executor: trs = executor.map(processStrategy, stocks) for tr in trs: try: if tr: finalPool.estimate(tr)
if const.REFRESH_DATA: dataloader.downloadStockData(stock) prices = dataloader.importData(4, stock['file']) const.currentSecId = stock['id'] tr = strategy.runStrategy(prices) return tr except: return None #finalPool.estimate(tr) #q.put(tr) if __name__ == "__main__": rwlogging.clearLog() if const.SOURCE_TYPE < 3: prices = dataloader.importData(const.SOURCE_TYPE, const.DATA_FILE) strategy.runStrategy(prices) if const.SOURCE_TYPE == 3: stocks = dataloader.importStockList(const.LIST_FILE) for stock in stocks: dataloader.downloadStockData(stock) if const.SOURCE_TYPE == 4: stocks = dataloader.importStockList(const.LIST_FILE) finalPool = Pool(100) with concurrent.futures.ProcessPoolExecutor(max_workers=const.MAX_PROCESS_NUM) as executor: trs = executor.map(processStrategy, stocks) for tr in trs: try: if tr: finalPool.estimate(tr) except: