Why does this get_data script fail?

Why does this script fail? x is a list with 200 RICs and attributes contains 22 fields. It even fails with chunksize=1.

chunksize = 5
i=0
w,err=ek.get_data(x[i:i+chunksize], attributes, { 'SDate': 0, 'EDate': -5, 'FRQ': 'FY', 'Curn': 'EUR'})
with open('SAMPLE.csv', 'a') as f:
w.to_csv(f, sep=';',decimal=',')
for i in range (chunksize, len(x), chunksize):
print(i)
w,err=ek.get_data(x[i:i+chunksize], attributes, { 'SDate': 0, 'EDate': -5, 'FRQ': 'FY', 'Curn': 'EUR'})
with open('SAMPLE.csv', 'a') as f:
w.to_csv(f, sep=';',decimal=',',header=False)

returns

5
10
15
20
Backend error. 400 Bad Request

Looking forward to your comments.

Best Answer

  • chavalit-jintamalit
    Answer ✓

    Hi @mbp

    Please refer to this guideline.

    And read "What happens when a limit is reached?" section.

    Basically, I believe that you are sending request too often.

    You should add some delay between each requests.

Answers

  • I know why. The time-out occurs at no. 21. Do you know how to make an exception handler, so it continues through the list?

  • @mbp
    "If you randomly experience an issue with data requests returning "Backend error. 400 Bad Request", first see my answer on this thread.
    For the answer about how to catch exceptions when using get_data method see this thread.