question

Upvotes
Accepted
1 0 0 1

Issues with rd.open_session (python API)

hey guys, I'm trying to run the following lines:


import refinitiv.data as rd

rd.open_session()

trading_instrument = 'ESc1'
prices = rd.get_history(
universe = trading_instrument,
fields=['TRDPRC_1'],
start = "1997-01-01",
end = "2024-07-31",
)
prices = prices.loc[:,~prices.columns.duplicated()]
prices


and now I'm getting the following errors:

---------------------------------------------------------------------------

RDError Traceback (most recent call last)

Cell In[41], line 2

1 trading_instrument = 'ESc1'

----> 2 prices = rd.get_history(

3 universe = trading_instrument,

4 fields=['TRDPRC_1'],

5 start = "1997-01-01",

6 end = "2024-07-31",

7 )

8 prices = prices.loc[:,~prices.columns.duplicated()]


File ~\AppData\Local\anaconda3\Lib\site-packages\refinitiv\data\_access_layer\get_history_func.py:206, in get_history(universe, fields, interval, start, end, adjustments, count, use_field_names_in_headers, parameters)

204 if exceptions and all(exceptions):

205 except_msg = "\n\n".join(exceptions)

--> 206 raise RDError(-1, except_msg)

208 if not any({adc_data, hp_data, cust_inst_data}):

209 return DataFrame()


RDError: Error code -1 | No data to return, please check errors: ERROR: No successful response. (403, {"ErrorCode":1401,"ErrorMessage":"Application id RD-PYTHON-LIB is invalid"})



Last night it did execute it and pulled out data normally, but this time I got that error. Does anyone know how to sort this out?? I'd much appreciate any help.

Thanks,

Ernesto

pythonworkspace#productpython apirefinitiv-data-library
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.

Hi @ernesto.quiros

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply, and then close the question. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Upvotes
Accepted
6.9k 21 3 6

Hi @ernesto.quiros,

When starting with the RD Lib. For Python, I'd suggest reading the articles "LSEG’s Refinitiv Data Library for Python and its Configuration Process" and "Summary of Common LSEG Refinitiv APIs".

As per the former of the two articles, you can use `rd.open_session()` if you have the Workspace or Eikon Desktop Application running on the machine where you run your code to create a session authentifying yourself to LSEG’s services. The RD Lib. is created to search for configuration files that includes information such as your App Key, which are basically your username and password put together. (The App Key does not actually include your username and password, but it works as such, in effect, without any privacy issues.)

For more information, I'd read the two aforementioned articles.


In your case I suspect one of two things:

(i) the Workspace or Eikon Desktop Application running on the machine might be crashing, which would break the authentifying process. Have you noticed anything wrong with the Desktop App while running your code?

(ii) the LSEG service might be overloaded, in which case I would suggest coding defensively, using try loops and `time.sleep` in between each API call.

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

Hi Jonathan,

Thanks a lot for the prompt response and suggestions to my inquiry. At the time I opened this thread and tried downloading data through the python API I did have the workspace platform open and operating 100% in the background. It seems there's a sort of time limit for which the open session expires, as I re-launched my jupyter notebook, executed again that part of the code and worked again normally. I'll bear in mind your suggestion regarding the try loops in the future, though.

Thank you !

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.