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
16 1 1 1

For loop over future quotes gives Error code 2504 and takes forever

I need to retrieve futures for naphtha. I do so using the following code.

I added the code from (Error Code 2504- Occurs at random times in code, how is this error caused and how is it solved? - Forum | Refinitiv Developer Community ) to solve for error code 2504.

for looping over this range is very slow and I wonder if there are faster ways to get a future curve.

for i in range(2,22):
while True:
try:
data = ek.get_timeseries('TFSNAPTFPMc'+str(i),
fields = 'CLOSE',
start_date = pricing_day.strftime('%Y-%m-%d %H:%M:%S'),
end_date = pricing_day.strftime('%Y-%m-%d %H:%M:%S'),
interval = 'daily') #interval
break
except ek.EikonError as err:
if err.err_code != 2504:
# request failed with other reason than 2504 error code
break
# let's retry after a delay
timer.wait(1)
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
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.

1 Answer

· Write an Answer
Upvotes
Accepted
16 1 1 1

Instead of for-looping I used a list of tickers as input for get_timeseries, dramatically increasing the speed.

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.