Hide code cell content

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

Authenticating with a configuration file

By default, the LSEG Data Library for Python expects you to provide credentials in a configuration file named lseg-data.config.json.

At minimum, it must include your application key, as well as the username and password you use to access the LSEG web portal.

Start by copying and pasting the following snippet into a file named lseg-data.config.json. Replace the placeholder values with your credentials.

{
  "sessions": {
    "default": "platform.rdp",
    "platform": {
      "rdp": {
        "app-key": "YOUR APP KEY GOES HERE!",
        "username": "YOUR RDP LOGIN OR MACHINE GOES HERE!",
        "password": "YOUR RDP PASSWORD GOES HERE!",
        "signon_control": true
      }
    }
  }
}

Note

A fuller example of all the configuration options available can be found in the official documentation.

Unless you provide further instruction your Python script will expect the configuration file to be located in the same directory as the script you are running. Once the file is in place, you can import the library and open a session by running the following code:

import lseg.data as ld

ld.open_session()
<lseg.data.session.Definition object at 0x7f6ad03c63c0 {name='rdp'}>

Verify the session is open by executing a query for the current price of Thomson Reuters stock. You should back a table of data.

ld.get_history('TRI.N')
TRI.N TRDPRC_1 HIGH_1 LOW_1 ACVOL_UNS OPEN_PRC BID ASK TRNOVR_UNS VWAP BLKCOUNT BLKVOLUM NUM_MOVES TRD_STATUS SALTIM VWAP_VOL
Date
2025-09-18 160.56 169.32 160.52 64044 169.32 159.87 160.82 10493940 163.8552 <NA> <NA> 1601 <NA> 71993 64044
2025-09-19 162.52 162.79 160.28 38953 161.855 162.23 163.62 6295321 161.6132 <NA> <NA> 1013 <NA> 71997 38953
2025-09-22 163.03 163.09 161.12 27899 161.51 162.85 163.21 4517233 161.9138 <NA> <NA> 777 <NA> 71998 27899
2025-09-23 160.79 163.02 160.44 15740 162.52 160.68 161.02 2542013 161.5002 <NA> <NA> 474 <NA> 71998 15740
2025-09-24 157.71 160.83 157.6 25138 160.83 157.58 157.92 3997779 159.0333 <NA> <NA> 599 <NA> 71985 25138
2025-09-25 158.01 159.22 157.56 13687 159.21 157.89 158.25 2165748 158.234 <NA> <NA> 452 <NA> 71997 13684
2025-09-26 156.96 157.9 156.65 17707 157.1 156.83 157.15 2783522 157.199 <NA> <NA> 460 <NA> 71991 17707
2025-09-29 156.16 157.53 155.83 16320 157.53 156.01 156.35 2554292 156.513 <NA> <NA> 443 <NA> 71985 16320
2025-09-30 155.29 157.3 155.11 27077 155.97 155.16 155.5 4220310 155.8633 <NA> <NA> 548 <NA> 71993 27077
2025-10-01 152.61 155.27 152.61 33684 154.89 152.47 152.78 5169990 153.485 <NA> <NA> 595 <NA> 71961 33684
2025-10-02 151.46 152.21 149.93 62914 152.21 151.29 151.66 9495920 150.9349 <NA> <NA> 807 <NA> 71998 62914
2025-10-03 153.0 153.57 150.77 30037 151.04 152.76 153.16 4571567 152.1978 <NA> <NA> 656 <NA> 71997 30037
2025-10-06 151.96 152.48 151.115 20566 151.515 151.86 152.17 3121929 151.8005 <NA> <NA> 525 <NA> 71943 20566
2025-10-07 151.53 152.21 150.58 15948 151.52 151.39 152.12 2414595 151.4043 <NA> <NA> 416 <NA> 71999 15948
2025-10-08 151.64 151.92 150.97 16321 151.21 151.54 151.89 2473209 151.5354 <NA> <NA> 423 <NA> 71996 16321
2025-10-09 150.08 150.94 149.655 13269 150.94 149.94 150.2 1992302 150.1471 <NA> <NA> 437 <NA> 71995 13269
2025-10-10 151.325 152.07 149.55 30173 150.79 151.27 151.62 4559474 151.1111 <NA> <NA> 624 <NA> 71990 30173
2025-10-13 152.66 154.11 152.66 15623 152.9 152.4 152.75 2392604 153.1463 <NA> <NA> 456 <NA> 71887 15623
2025-10-14 154.68 155.6 153.27 35461 153.52 154.51 154.81 5483428 154.6327 <NA> <NA> 646 <NA> 71996 35461
2025-10-15 159.34 160.61 157.845 33729 157.845 159.19 159.44 5376247 159.3954 <NA> <NA> 732 <NA> 71986 33729

The library expects you to close your session when you’re finished. You can do so by running the following code:

ld.close_session()

Specifying a configuration file

If you want to store your configuration file in a different location, you can specify its path when you open a session.

For example, if you gave your configuration file with a shorter name and stored it in a subdirectory named config, you could open a session by running something like the following:

ld.open_session(config_name="./config/lseg.json")