Skip to content

This project demonstrates how to extract the time series from LSEG Workspace platform using Data Library for Python and forecasting the time series using ARIMA models.

License

Notifications You must be signed in to change notification settings

LSEG-API-Samples/Article.DataLibrary.Python.TimeSeries.Forecast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time Series Forecasting with Data Library for Python and Workspace Platform

  • Last update: April 2025
  • Environment: Windows
  • Compiler: Python
  • Prerequisite: LSEG Workspace desktop application with access to Data Library.

Project Overview

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.

Introduction to the Data Library for Python

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.

Figure-1

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:

Disclaimer

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

Introduction to ARIMA models

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.

Prerequisite

This example requires the following dependencies softwares and libraries.

  1. LSEG Workspace desktop application with access to Data Library for Python.
  2. Python (Ananconda or MiniConda distribution/package manager also compatible).
  3. 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.

How to run this example

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.

Running the Notebook example.

  1. Open a Command Prompt and go to project's folder

  2. 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
  3. Once the environment is created, activate a virtual environment named ld_forecast with this command in a Command Prompt

    $>ld_forecast\Scripts\activate
  4. 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!"
                }
            }
        }
    }
  5. Run the following command in a Command Prompt to install the project dependencies

    $>(ld_forecast) pip install -r requirements.txt
  6. 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
  7. Open ld_arima_model.ipynb Notebook document, then follow through each notebook cell.

    Figure-2

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.

Conclusion

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.

Acknowledgements

Special thank to Pimchaya, original creator of this project.

References

You can find more detail regarding the Data Library and related technologies for this Notebook from the following resources:

For any question related to this example or Data Library, please use the Developers Community Q&A Forum.

About

This project demonstrates how to extract the time series from LSEG Workspace platform using Data Library for Python and forecasting the time series using ARIMA models.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published