[Python] How do you make faster API calls using multithreading without using requests in...

Discussão em 'Python' iniciado por Stack, Fevereiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to receive historical stock data for every company in the S&P 500. The problem is that it is taking a really long time to get the data.

    from ApiStuff import ApiStuff
    import fundamentalanalysis as fa
    import pickle

    tickers = pickle.load(open('S&P500_TICKERS.dat', 'rb'))

    api_key = ApiStuff.api_key
    data_from_tickers = []

    for ticker in tickers:
    balance_sheet_annually = fa.balance_sheet_statement(ticker, api_key, period="annual")
    data_from_tickers.append(balance_sheet_annually)


    I tried searching on the internet on how to speed it up, but they use other modules (e.g. requests, aiohttp) for making the retrieval of the data faster and I am dependent on this module (fundamentalanalysis) to retrieve fundamental data.

    Is there a way for me to still use this module and make API requests faster via the methods described?

    Continue reading...

Compartilhe esta Página