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)