Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
9 3 4 5

Error handling for get_timeseries()

I am using a get_timeseries() function in a loop over a long list of stocks and get different errors depending on context (I am aware of the reasons for the errors):

- No data available for the requested data range.

- Client Error: Too many requests, please try again later

Is there a way to handle these errors differently? For example, I want skip the iteration that returns "no data available" and completely stop the loop execution if "too many requests" error shows, something like this

for ticker in ticker_list:         
        try:
            prices = ek.get_timeseries(ticker, interval = 'daily)         
        except NoDataAvailableError:
            continue
        except ClientError:
            break
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apierror
icon clock
10 |1500

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

Upvotes
Accepted
18.2k 21 13 21

Hi @oik22

Eikon Data API raises EikonError error.

This is the sample code to catch it: (I simulated 2 cases, too many ric and invalid ric)

Under the except ek.EikonError, you can handle it according to your requirement.

To either break or continue your loop.



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

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

Upvotes
18.2k 21 13 21

Hi @oik22

I think your handles make sense.

Maybe add a few delays between each loop too.

icon clock
10 |1500

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

Upvotes
9 3 4 5

Thanks @chavalit.jintamalit

I am actually looking for the specific handles or codes for the errors that Eikon API throws in these two cases: (1) "no data available for the data range" (2) "too many requests", so that I can distinguish between them. The exception handles "NoDataAvailableError" and "ClientError" are just some random names I came up with as an example for illustrative purposes. I do not know what the actual Eikon error handles are for these two cases. Like the different Python build-in exceptions such as ValueError or ZeroDivisionError, that's what I am looking for.

icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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