For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 1 1

Recommended code pattern for handling Eikon get_data timeout

Hi,

I'm a newbie to Eikon API


Is there a proscribed code pattern for handling timeouts? I have making a call to `get_data` in a loop: Each request takes about 10s to return but occasionally I get a Timeout (408/504).

I could just trap the timeout error and re-submit using following code as a starting point, but I just wondered is there an accepted/recommended code pattern to use?


thanks



    e = None
    try:
        ek.get_data(instruments, fields)
    except ek.EikonError as err:
        e = err
        # do I trap here and re-call get_data??
        raise Exception(f'Eikon error {e.code}\n{e.args}\n{e.message}')



eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythontime-out
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
18k 21 12 20

Hi @john.lupton

I would add a while loop with a success flag.


ric = ['PEUP.PA']
fields = ['TR.RetireDate']

isSuccess = False

while (not isSuccess):
    try:
        df,e = ek.get_data(ric, fields)
        isSuccess = True
    except ek.EikonError as err:
        raise Exception(f'Eikon error {e.code}\n{e.args}\n{e.message}')

## the code here, already success in API call ##
print(df)



If your API call requires 10 seconds, I can assume that you require a large amount of data.

Please try to split the universe or period to reduce the amount of the data in one API call.

This would raise the success rate of the API call.


ahs.png (27.0 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@chavalit.jintamalit thank you for taking the time to respond. Could you clarify what do you mean by "split the universe" - I am asking for multiple fields across multiple RICs so do you mean reduce RICs or fields or both?

Thanks

Hi @john.lupton

For example:

If you request data for 2000 RIC, you may split the RIC to a smaller number.

If you request 20 RIC, but the data is 10 years of daily data, you may split the period into a smaller period.

If you request 10 RIC, but 1000 fields, you may split the field? or RIC? into a smaller list.

The point is to reduce the amount of data being transfer.

The bigger the amount of the data, the more chance that something may go wrong.

So try to balance it for your application.

Click below to post an Idea Post Idea