- Last update: April 2025
- Environment: Windows
- Compiler: Python
- Prerequisite: LSEG Workspace desktop application with access to Data Library.
Last Updated: April 2025
This project demonstrates how to extract the time series from LSEG Workspace platform using Data Library for Python (LSEG Data Library, aka Data Library version 2). Then, we can use it for forecasting the time series e.g. using ARIMA (Autoregressive integrated moving average) models in this notebook.
Let me start by give you an introduction to the Data Library. 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.
That covers an overview of the Data Library
My next point is the ARIMA model. The ARIMA models are a class of statistical models for analyzing and forecasting time series data. ARIMA consists of the following key aspects of the model
- AR: Autoregression. A model that uses the dependent relationship between an observation and some number of lagged observations.
- I: Integrated. The use of differencing of raw observations (e.g. subtracting an observation from an observation at the previous time step) in order to make the time series stationary.
- MA: Moving Average. A model that uses the dependency between an observation and a residual error from a moving average model applied to lagged observations.
Each of these components are explicitly specified in the model as a parameter. A standard notation is used of ARIMA(p,d,q) where the parameters are substituted with integer values to quickly indicate the specific ARIMA model being used.
The parameters of the ARIMA model are defined as follows:
- p: The number of lag observations included in the model, also called the lag order.
- d: The number of times that the raw observations are difference, also called the degree of differencing.
- q: The size of the moving average window, also called the order of moving average.
A value of 0 can be used for a parameter, which indicates to not use that element of the model. This way, the ARIMA model can be configured to perform the function of an ARMA model, and even a simple AR, I, or MA model.
That’s all I have to say about the ARIMA models.
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 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 ld_forecast for the project.
$>python -m venv ld_forecast
-
Once the environment is created, activate a virtual environment named
ld_forecast
with this command in a Command Prompt$>ld_forecast\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
$>(ld_forecast) 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.
$>(ld_forecast)>notebook>jupyter lab
-
Open ld_arima_model.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.
At the end of this project, you should be able to get time series from LSEG Workspace platform using get_history
function in Data Library for Python. Then, you can use the time series with ARIMA model to make forecasts or use the time series for other purposes.
Special thank to Pimchaya, original creator of this project.
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
- 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.
- statsmodels library page.
- What are ARMIA models? - IBM document page.
- How to Create an ARIMA Model for Time Series Forecasting in Python blogpost.
For any question related to this example or Data Library, please use the Developers Community Q&A Forum.