Dear Developer Community,
I want to download ESG and Pillar scores for all US stocks from 2011 to 2023 on a quarterly basis via the Eikon Data API.
I am using the get_data(..) function with the following specifications
fields = ["TR.TRESGScore", "TR.EnvironmentPillarScore", "TR.SocialPillarScore", "TR.GovernancePillarScore"]
parameters= {'Frq':'Q', 'SDate':'2010-12-31','EDate':'2024-12-31'}
I already have all ISINs from WRDS, saved as a list in Python. Also, I made sure to delete all <NA> entries leaving me with around 14.000 ISINs
I created a chunking function which requests 100 chunks per iteration.
def chunk_list(first, chunk_size):
for i in range(0,len(first), chunk_size):
yield first[i:i + chunk_size]
chunk_size = 100
I used the chunking function with get_data:
for chunk in chunk_list(ISIN_list, chunk_size):
df, err = ek.get_data(chunk, fields=fields, parameters= parameters)
df_complete.append(df)
print(f'{len(chunk)} chunks completed')
Problem Description:
My problem is that the funtion works for the first few iterations but than I get a 400 Bad Request Error.
...
100 chunks completed
100 chunks completed
100 chunks completed
100 chunks completed
100 chunks completed
100 chunks completed
100 chunks completed
100 chunks completed
Backend error. 400 Bad Request
...
refinitiv.dataplatform.errors.RDPError: Error code 400 | Backend error. 400 Bad Request
How I tried solving it:
I searched the forum for similar issues and already did the following:
- I tried using smaller chunks sizes (e.g. 50 and 10), but it did not help
- I tried adding a random sleep timer but it did not help
time.sleep(random.randint(0,3))
I haven't find a solution yet...
The Helpdesk suggested I should ask the Developer Community.
Do you have any suggestions or soltions to my problem?
Thank you very much in advance!