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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
16 0 0 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-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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
16 0 0 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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea