Skip to content

Commit fa8262d

Browse files
committed
Updated README.md file
1 parent 30202fd commit fa8262d

4 files changed

Lines changed: 69 additions & 8 deletions

File tree

README.md

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
11
# Concurrent Data Platform API Calls with Python Asyncio and Data Library for Python
22

3-
A Jupyter notebook demonstrating how to issue multiple [LSEG Data Library for Python](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python) API requests concurrently using Python's built-in `asyncio` module.
3+
- Version: 1.0
4+
- Last update: June 2026
5+
- Environment: Python + JupyterLab + Data Platform Account
6+
- Prerequisite: Data Platform access/entitlements
47

58
---
69

710
## Overview
811

9-
Rather than fetching market data sequentially, this project demonstrate how to use `asyncio.gather` with Data Library Historical `get_data_async` method to send multiple historical price data concurrently.
12+
This project is a semi-sequel to my [Concurrent Data Platform API Calls with Python Asyncio and HTTPX](https://github.com/LSEG-API-Samples/Example.RDP.Python.Async.HTTPX) project. That project shows how to use Python and the [HTTPX](https://www.python-httpx.org/) library to make concurrent HTTP REST requests to LSEG [Data Platform](https://developers.lseg.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis) asynchronously. This project shifts away from manually sending HTTP REST requests and instead uses the easy-to-use [LSEG Data Library for Python](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python). The Data Library for Python Historical Pricing module offers the `get_data_async` method to request historical data asynchronously, letting developers send multiple requests concurrently without blocking the process.
13+
14+
15+
**Note**: This project is based on the Data Library for Python version 2.1.1. The library behavior might change in future releases.
16+
17+
---
18+
19+
## (Recap) What are Synchronous and Asynchronous Execution Models?
20+
21+
**Synchronous** code runs tasks one at a time — each request must complete before the next one starts. The program blocks and waits at every I/O-bound call, so if a request takes 60 seconds, nothing else runs for those 60 seconds. Fine for a single request, but a real bottleneck when fetching data with many calls.
22+
23+
![synchronous](images/02_synchronous_simple.png)
24+
25+
**Asynchronous** code lets multiple tasks run concurrently. While one request is waiting for a network response, the event loop hands control to the next task instead of sitting idle.
26+
27+
![asynchronous](images/04_asynchronous_simple.png)
28+
29+
The real payoff comes when you have **many requests to make**. With `asyncio.gather()` and `asyncio.TaskGroup()`, all requests are fired concurrently so the total time is roughly that of the single slowest response — not the sum of all response times.
30+
31+
---
32+
33+
## Throttling and Rate Limits
34+
35+
The Data Platform API request limits (throttles) to effectively manage and protect its service and ensure fair usage across the non-streaming content.
36+
37+
An application would receive an error from the API call if an application reached or exceeds a limit (especially with the Asynchronous HTTP calls). You required to make some necessary adjustments to rectify the interaction with the API and retry the respective API call.
38+
39+
Two different server errors on API request limits are:
40+
41+
| **HTTP Status** | **Detail** |
42+
| --- | --- |
43+
| **429** | **Error Message**: too many attempts |
44+
| | **Description**: A per account limit where the number of requests per second is limited for each account accessing the platform. If this limit is reached, applications will receive a standard HTTP error (HTTP 429 too many requests). |
45+
| | **Suggestion**: Please reduce the number of requests per second and retry. |
46+
47+
Please find more detail regarding the Data Platform HTTP error status messages from the [RDP API General Guidelines](https://developers.lseg.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis/documentation) document page.
48+
49+
The Historical Pricing endpoint rate limits information is available on the **Reference** tab of the [Data Platform API Playground](https://apidocs.refinitiv.com/Apps/ApiDocs) page. The current rate limits (**As of Mar 2026**) is as follows:
50+
51+
![historical rate limit](images/05_historical-pricing-ratelimits.png)
52+
53+
---
54+
55+
## Prerequisites
56+
57+
- Python 3.11+
58+
- LSEG Data Platform credentials with Historical Pricing permission:
59+
- Machine ID
60+
- Password
61+
- AppKey
62+
63+
Please your LSEG representative or account manager for the Data Platform Access
1064

1165
---
1266

@@ -38,9 +92,17 @@ Rather than fetching market data sequentially, this project demonstrate how to u
3892

3993
---
4094

41-
## Setup
95+
## Included Notebooks
96+
97+
| Notebook | Description |
98+
|---|---|
99+
| [ld_notebook_async_gather.ipynb](notebook/ld_notebook_async_gather.ipynb) | Demonstrates how to request multiple RICs concurrently using the Data Library Historical Pricing `get_data_async` method combined with `asyncio.gather()`. Covers Events and Summaries definitions, error handling for invalid RICs and fields, and how `return_exceptions=True` keeps all results — successes and failures — in one place. |
100+
101+
---
102+
103+
## Project Setup
42104

43-
### 1. Create and activate a virtual environment
105+
1. Create and activate a virtual environment
44106

45107
```powershell
46108
# Windows (PowerShell)
@@ -54,14 +116,14 @@ python3 -m venv .venv
54116
source .venv/bin/activate
55117
```
56118

57-
### 2. Install dependencies
119+
2. Install dependencies
58120

59121
```powershell
60122
(venv)$>python -m pip install --upgrade pip
61123
(venv)$>python -m pip install -r requirements.txt
62124
```
63125

64-
### 3. Configure credentials
126+
3. Configure credentials
65127

66128
Copy `.env.example` to `.env` inside the `notebook/` folder and fill in your credentials:
67129

@@ -71,7 +133,7 @@ LSEG_MACHINE_ID=your_machine_id_here
71133
LSEG_PASSWORD=your_password_here
72134
```
73135

74-
### 4. Run the notebook
136+
4. Run the notebook
75137

76138
Open `notebook/ld_notebook_async_gather.ipynb` in JupyterLab or VS Code and run the cells in order.
77139

@@ -112,7 +174,6 @@ You can find more detail regarding the Data Library and Python Asyncio from the
112174
- [Python Asyncio library](https://docs.python.org/3/library/asyncio.html) page.
113175
- [A Conceptual Overview of asyncio](https://docs.python.org/3/howto/a-conceptual-overview-of-asyncio.html#a-conceptual-overview-of-asyncio) article.
114176
- [Python's asyncio: A Hands-On Walkthrough](https://realpython.com/async-io-python/)
115-
- [Asynchronous HTTP Requests in Python with HTTPX and asyncio](https://www.twilio.com/en-us/blog/asynchronous-http-requests-in-python-with-httpx-and-asyncio)
116177
- [Asyncio gather function document](https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) page.
117178
- [Asyncio TaskGroup function document](https://docs.python.org/3/library/asyncio-task.html#task-groups) page.
118179

images/02_synchronous_simple.png

85.7 KB
Loading

images/04_asynchronous_simple.png

88.5 KB
Loading
73.1 KB
Loading

0 commit comments

Comments
 (0)