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

Author:

Jonathan Legrand
Developer Advocate Developer Advocate

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 file 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.

  • Login
  • Please Login
Contact Us MyRefinitiv