guanquann / Stocksera

Finance application that provides more than 60 different alternative data to retail investors
MIT License
620 stars 103 forks source link

with helpers.py #50

Open tankisstank opened 7 months ago

tankisstank commented 7 months ago

There are one issue with the function get_ticker_list_stats(ticker_list), if the given ticker list is too long, you will have an error which told you to reduce the length, so I split it to 50 each, I think 100 is still ok. And remember with financialmodelingprep free tier, you only have limited number of request.

def get_ticker_list_stats(ticker_list):
    #print(ticker_list)
    chunks = split_list(ticker_list, 50)
    df = pd.DataFrame()
    for chunk in chunks:
       #AdDS4dPu2zBhQJV9pwTVEDMWFjFaNdxf
        try:
            r = requests.get(f"https://financialmodelingprep.com/api/v3/quote/{','.join(chunk)}?"
                         f"apikey={config_keys['FMP_KEY']}").json()
            #print(r)
            df = pd.concat([df,pd.DataFrame(r)])
        except:
            print()
    return df