Python - Multithreading - Yahoo Finance download - Runtime Error: can't start new thread

Viewed 160

I am quite new to coding so pardon me if this is basic stuff. I did not even know what multithreading was until I found this error and started to look around.

When I run the following code. I get Runtime Error: can't start new thread

stock_prices_daily = yf.download(ticker_daily, group_by='Ticker', start = '1990-01-01')

ticker_daily is a list of >5467 tickers. All these tickers have data from Yahoo Finance. I already tried (I was able to get price data for all of them)

I use Spyder as console with Anaconda.

As a workaround I use the below loop but I think it is slowing down the code and I would like to understand if there is a better approach to manage multithreading with YF.

for i in list(range(0,len(ticker_daily))):
    temp_price = yf.download(ticker_daily[i], start = '1990-01-01')
    temp_price['Ticker'] = ticker_daily[i]
    if i == 0:
        stock_prices = temp_price 
    else:
        stock_prices = stock_prices.append(temp_price)
    print(i)
0 Answers
Related