This project demonstrates how to run the LSEG Data Library for Python (aka Data Library version 2) inside a container. This means you can package the application and run it anywhere without worrying about installing Python or managing dependencies on your local machine.
What you'll learn:
- How to containerize a Python application that accesses LSEG financial data
- How to connect to LSEG's cloud platform (Platform Session) from within a container
- How to build and run containers using Docker or Podman
Technology used:
- Data Library for Python version 2.1.1
- Python 3.12
- Docker or Podman (containerization tools)
Before you begin, make sure you have:
- LSEG Credentials: An account with access to the Delivery Platform (Data Platform) that includes Pricing and Historical Pricing permissions
- Don't have credentials? Contact your LSEG representative for access
- Containerization Tool: Either Docker Desktop or Podman installed on your computer
- Internet Connection: Required to download packages and connect to LSEG services
The Data Library for Python is a powerful toolkit that gives you easy access to LSEG's vast collection of financial data and services. Think of it as a universal adapter that lets you access the same data whether you're working from:
- Your desktop (Workspace application)
- The cloud (Delivery Platform)
- Real-time streaming services
Key benefits:
- Write code once, use it across multiple platforms
- Simple, consistent interface regardless of your data source
- Available in Python, .NET, and TypeScript
The Data Library are available in the following programming languages:
Want to learn more? Check out these resources:
The Data Library can connect to data in different ways:
- Desktop Session: Requires the LSEG Workspace desktop application running on your computer
- Platform Session: Connects directly to LSEG's Delivery Platform (aka Data Platform, RDP) on the Cloud. No desktop app needed.
For containerized applications, we use Platform Session because:
- Containers can't access the Workspace desktop applications running on your host computer
- Platform Session consumes data from cloud
- Your container can run anywhere with internet access
Think of a Dockerfile as a recipe for building your application's container. This project uses a simple approach to:
- Start with a pre-made Python environment (Python 3.12)
- Install the required Python packages
- Copy your application files
- Set up the container to run your application automatically
Note about SSL certificates:
The use of --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --no-cache-dir command inside a Dockerfile is to avoid LSEG beloved Zscaler that blocks access to PyPI repository by default (don't ask me why).
The command bypass SSL certificate verification. If you need the SSL verification, please change Dockerfile's RUN commands to the following statements:
RUN pip install --upgrade pip && \
pip install --no-cache-dir --user -r requirements.txtFollow these steps to build and run your containerized application. The examples use podman commands, but if you're using Docker, simply replace podman with docker.
Download or unzip this project to a folder on your computer.
-
Open the lseg_data.config.json file in a text editor
-
Add your LSEG credentials:
"sessions": { "default": "platform.ldp", "platform": { "ldp": { "app-key": "YOUR APP KEY GOES HERE!", "username": "YOUR LDP LOGIN OR MACHINE GOES HERE!", "password": "YOUR LDP PASSWORD GOES HERE!", "signon_control":true }, "ldpv2":{ "client_id": "Service-ID (Client ID V2)", "client_secret": "Client Secret", "signon_control":true, "app-key": "" } } }
-
Important: Choose the correct authentication version:
- Version 1 (Machine-ID): Set
"default"to"platform.ldp" - Version 2 (Service-ID): Set
"default"to"platform.ldpv2"
- Version 1 (Machine-ID): Set
-
Open a command prompt or terminal
-
Navigate to the project folder
-
Run this command to build the container image:
podman build -t ld_app .This process may take a few minutes as it downloads and installs everything needed.
-
When complete, verify the image was created:
podman images
You should see
ld_appin the list.
Start the container with this command:
podman run -it --name ld_app ld_appYour application will now run and connect to LSEG's data platform!
To stop the application: Press Ctrl+C
When you're done, you can remove the container and image:
Remove the container:
podman rm ld_appRemove the image:
podman rmi ld_appThe project supports both Podman and Docker Containerization tool. I have tested the project with Docker and it works fine.
Want to dive deeper? Here are some helpful resources:
- LSEG Data Library for Python
- Data Platform
- Account authorization V1 to V2 migration cheat sheet article.
- Essential Guide to the Data Libraries - Generations of Python library (EDAPI, RDP, RD, LD)
- LSEG Data Library for Python and its Configuration Process
- A beginner's guide to Python containers
- How to “Dockerize” Your Python Applications
- Containerize a Python application
For any questions related to this example or the LSEG Data Library, please use the Developer Community Q&A Forum.






