When using FOR loop to request get_timeseries, it sometimes returns TIME OUT

When I use get_timeseries to get Future's close price, I choose to use t FOR loop to get a list of contracts' data, but sometimes the get_timeseries returns TIMEOUT. Even if I set a 1 second time.sleep for each loop. How can I make sure that the get_timeseries can work well?

My code is like this:

for i in range(len(ric_list)):
try:
data = ek.get_timeseries([ric_list[i]], fields=["CLOSE"], start_date=before, end_date=today, interval='daily', count=10000)
except:
data = pd.DataFrame(columns=[ric_list[i]])
data_set = pd.concat([data_set,data],axis=1)
time.sleep(1)

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @matt.huang

    Thank you for reaching out to us.

    Is it client request timeout or server timeout?

    Please try to use the Refinitiv Data Library for Python instead.

    You can refer to the historical pricing example on GitHub. With this library, you can configure the client request timeout via coding or configurations. Please refer to this discussion.

    If it is server timeout, the number of items, fields, date range, or count should be reduced.