You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69-8Lines changed: 69 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,66 @@
1
1
# Concurrent Data Platform API Calls with Python Asyncio and Data Library for Python
2
2
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
4
7
5
8
---
6
9
7
10
## Overview
8
11
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
+

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.
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:
- 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
10
64
11
65
---
12
66
@@ -38,9 +92,17 @@ Rather than fetching market data sequentially, this project demonstrate how to u
38
92
39
93
---
40
94
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
42
104
43
-
### 1. Create and activate a virtual environment
105
+
1. Create and activate a virtual environment
44
106
45
107
```powershell
46
108
# Windows (PowerShell)
@@ -54,14 +116,14 @@ python3 -m venv .venv
54
116
source .venv/bin/activate
55
117
```
56
118
57
-
### 2. Install dependencies
119
+
2. Install dependencies
58
120
59
121
```powershell
60
122
(venv)$>python -m pip install --upgrade pip
61
123
(venv)$>python -m pip install -r requirements.txt
62
124
```
63
125
64
-
### 3. Configure credentials
126
+
3. Configure credentials
65
127
66
128
Copy `.env.example` to `.env` inside the `notebook/` folder and fill in your credentials:
-[A Conceptual Overview of asyncio](https://docs.python.org/3/howto/a-conceptual-overview-of-asyncio.html#a-conceptual-overview-of-asyncio) article.
114
176
-[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)
116
177
-[Asyncio gather function document](https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) page.
117
178
-[Asyncio TaskGroup function document](https://docs.python.org/3/library/asyncio-task.html#task-groups) page.
0 commit comments