- Last update: April 2025
- Environment: Windows
- Compiler: Python
- Prerequisite: LSEG Workspace desktop application with access to Data Library.
When investing in a retirement fund using DCA(Dollar-Cost Averaging) strategy, does it perform better than the inflation rate?
In this project, we will find out what is the past inflation rate in Thailand using the Data Library for Python to consume data from the Workspace Desktop application.
Then we will find out how the DCA on a fund performs. And finally we will plot a bar chart to compare the average return against inflation.
The Data Library for Python provides a set of ease-of-use interfaces offering coders uniform access to the breadth and depth of financial data and services available on the Workspace, RDP, and Real-Time Platforms. The API is designed to provide consistent access through multiple access channels and target both Professional Developers and Financial Coders. Developers can choose to access content from the desktop, through their deployed streaming services, or directly to the cloud. With the Data Library, the same Python code can be used to retrieve data regardless of which access point you choose to connect to the platform.
The Data Library are available in the following programming languages:
For more deep detail regarding the Data Library for Python, please refer to the following articles and tutorials:
This project is based on Data Library Python versions 2.1.1 using the Desktop Session only.
This example requires the following dependencies softwares and libraries.
- LSEG Workspace desktop application with access to Data Library for Python.
- Python (Ananconda or MiniConda distribution/package manager also compatible).
- Jupyter Lab application.
Note:
- This Project has been qualified with Python version 3.11.5
- If you are not familiar with Jupyter Lab application, the following tutorial created by DataCamp may help you.
Please follow a step by step guide to setup your library and App-Key in "Desktop - Eikon or LSEG Workspace" of LSEG Data Library for Python Quick Start page .
Please note that the Workspace desktop application integrates a Data API proxy that acts as an interface between the Python library and the Workspace Platform. For this reason, the Workspace application must be running when you use the Data library.
The first step is unzip or download the example project folder into a directory of your choice, then choose how to run application based on your environment below.
-
Open a Command Prompt and go to project's folder
-
Run the following command in a Command Prompt to create a Python virtual environment named venv for the project.
$>python -m venv venv
-
Once the environment is created, activate a virtual environment named
venv
with this command in a Command Prompt$>venv\Scripts\activate
-
Go to project's notebook folder and update a contain in
lseg-data.config.json
file with the your App-Key{ "logs": { "level": "debug", "transports": { "console": { "enabled": false }, "file": { "enabled": false, "name": "lseg-data-lib.log" } } }, "sessions": { "default": "desktop.workspace", "desktop": { "workspace": { "app-key": "YOUR APP KEY GOES HERE!" } } } }
-
Run the following command in a Command Prompt to install the project dependencies
$>(venv) pip install -r requirements.txt
-
In the current Command Prompt, go to project's notebook folder. Run the following command to start Jupyter Lab in the notebook folder.
$>(venv)>notebook>jupyter lab
-
Open LD-Inflation-VS-DCA-Fund-Performance.ipynb Notebook document, then follow through each notebook cell.
Note: If you are using AnaConda/MiniConda, please refer to this Conda - Managing environments document for more detail about how create and activate environment with Conda.
You can find more detail regarding the Data Library and related technologies for this Notebook from the following resources:
- LSEG Data Library for Python on the LSEG Developer Community website.
- Data Library for Python - Reference Guide
- The Data Library for Python - Quick Reference Guide (Access layer) article.
- Essential Guide to the Data Libraries - Generations of Python library (EDAPI, RDP, RD, LD) article.
- Upgrade from using Eikon Data API to the Data library article.
- Data Library for Python Examples on GitHub repository.
- XIRR function
- XIRR function in Python.
For any question related to this example or Data Library, please use the Developers Community Q&A Forum.