avatarJonathan Legrand

Summary

The web content provides guidance on using the Refinitiv Data Library (RD Lib) for Python to connect to the London Stock Exchange Group's databases, emphasizing the importance of the configuration file for session authentication.

Abstract

The Refinitiv Data Library (RD Lib) for Python is a powerful tool for accessing financial data from the London Stock Exchange Group (LSEG). To establish a connection, users must authenticate via a session, which is facilitated by a configuration file. This file requires an App Key and may also need a Login Username and Password, depending on the session type chosen: "platform" or "desktop." The "platform" session works without the Eikon Desktop Application but requires credentials in the configuration file, while the "desktop" session relies on the Eikon Desktop Application being active on the user's machine. The RD Lib searches for configuration files in a specific order, including in-line paths, the code's directory, the user's directory, or from the desktop application itself if running. The article stresses the necessity of understanding the configuration file's location and contents to ensure proper authentication and session creation.

Opinions

  • The author considers the configuration file critical for establishing a session with LSEG's services.
  • The author suggests that the "desktop" session type is more convenient for users who have the Eikon Desktop Application running, as it bypasses the need for manual entry of credentials.
  • The author implies that understanding the search order for configuration files is important for developers to ensure the RD Lib uses the correct credentials.
  • The article assumes that readers are Python developers familiar with the RD Lib and are looking to streamline their connection process to LSEG's databases.

LSEG’s Refinitiv Data Library for Python and its Configuration Process

You can fine the original, full, article on the Developer Portal.

The Refinitiv Data Library (RD Lib) for Python is extremely powerful and gives you access to an ever expanding universe of financial data. To connect to the London Stock Exchange’s (LSEG’s) databases using the RD Lib., however, you will need to start a connection session to authenticate yourself to LSEG’s services; and that’s where the configuration file comes into play.

You can find a lot of information on connection sessions in EX-4.01.01-Sessions.ipynb, but in this article, I will focus more on the configuration file and the process by which it is used in creating sessions.

Configuration File

A quick word on the configuration file. You can find it here, and it contains all the information about the session you may want to create. You need to enter this information, namely :

  • your App Key (which is necessary)
  • your Login Username (which is not necessary)
  • your Password (which is not necessary)
  • your preference for default session, “platform” or “desktop”. More about these two session types can be found here, but all you need to know for this article is that the “desktop” session necessitates the Workspace/Eikon Desktop Application to be running on the machine where you run your code, and the “platform” one does not, but instead necessitates the ‘Login Username’ and ‘Password’ to be entered in the configuration file.

It may be that you did not create or use such a configuration file, in which case, if you are running the Workspace/Eikon Desktop Application (on the machine where you run your code), this information will be retrieved from the desktop application.

Sessions

There are two sessions, the “platform” and “desktop” sessions, with aforementioned characteristics. You can specify the preferable session with the text/string “rdp.platform” or “desktop.workspace” in the configuration file itself:

"sessions": {
        "default": "desktop.workspace",

or in-line, in your Python code:

import refinitiv.data as rd
rd.open_session(
    name="desktop.workspace")

In-lie preference takes precedence over the configuration file’s when it is specified.

If you have the Workspace or Eikon Desktop Application running on the machine where you run your code, you can simply run the below to create a session authentifying yourself to LSEG’s services:

rd.open_session()

But what is happening in the background?

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.) It searches for configuration files in a specific order that can be checked with

for i in rd._configure.get_config()._configs:
    print(i._config)

The order in question is:

1st: In-Line Path

You can specify the path to your configuration file in-line, as such:

import refinitiv.data as rd
rd.open_session(
    config_name="C:/Example.DataLibrary.Python-main/Configuration/refinitiv-data.config.json")

Note that you can specify both the `config_name` and `name` here:

import refinitiv.data as rd
rd.open_session(
    name="desktop.session",
    config_name="C:/Example.DataLibrary.Python-main/Configuration/refinitiv-data.config.json")

2nd: In Your Code’s Directory

Wherever you are running your code on your PC (Personal Computer), you can put your configuration fil there and the RD Lib. will look for it there 2nd.

E.g.: if I am running a .npynb Python file (i.e.: a Jupyter Nobebook) in the directory “C:\”, I can put my configuration file in that same directory (“C:\”) and make sure that it is named correctly (i.e.: “refinitiv-data.config.json”). If I did not specify the path of my configuration file in-line, in my Python code, then the RD Lib. will use it to create a session.

3rd: In Your User’s Directory

E.g.: on my Windows PC, it’s in “C:\Users\John”. For you, it will be similar, something like “C:\Users\YourComputerUsernameHere”. In that path, I can find the configuration file named “refinitiv-data.config.json”.

4th: Desktop Application Specification

If you have the Workspace or Eikon Desktop Application running on the machine where you run your code, then the RD Lib. will look, in last place, for configuration details from the Desktop Application; in which case a configuration file is not needed.

Conclusion

As you can see, the configuration file is essential, and you need to know where it lies to make sure that the correct credentials are being used.

Don’t hesitate to read more on the RD Lib.’s documentation here.

Python
Refinitiv
Configuration
Authentication
Recommended from ReadMedium