The LSEG Data Library for Python provides a set of ease-of-use interfaces offering your applications a uniform access to the breadth and depth of financial data and services available on the Data Platform.
With this library, the same Python code can be used to retrieve data whatever the access point you choose to connect your application to the Data Platform. It can be either via a direct connection, via Eikon, via LSEG Workspace, via CodeBook or even via a local Real-Time Distribution System.
The library provides several abstraction layers enabling different programming styles and technics suitable for all developers from Financial Coders to Seasoned Developers:
Using the Access layer is the easiest way to get LSEG data. The Access layer provides simple interfaces allowing you to rapidly prototype solutions within interactive environments such as Jupyter Notebooks. It has been designed for quick experimentation with our data and for Financial Coders specific needs.
The Content layer is the basement of the Access layer. It provides developers with interfaces suitable for more advanced use cases (synchronous function calls, async/await, event driven). The Content layer refers to logical market data objects like market data prices and quotes, fundamental & reference data, historical data, company research data and so on.
The Delivery layer is a low abstraction layer that defines interfaces used to interact with service agnostic delivery mechanisms of the Data Platform. The Delivery layer is a foundational component of the Content layer.
The Session layer defines interfaces allowing your application to connect to the Data Platform via different access points (either via a direct connection, via Eikon, via the LSEG Workspace, via CodeBook or even via a local Real-Time Distribution System).
from lseg.data.content import pricing
pricing_stream = ld.content.pricing.Definition(
universe=['EUR=', 'GBP=', 'JPY=', 'CAD='],
fields=['DSPLY_NAME', 'BID', 'ASK']
).get_stream()
pricing_stream.on_refresh(lambda pricing_stream, instrument_name, fields:
print(f"Refresh received for {instrument_name}: {fields}"))
pricing_stream.on_update(lambda pricing_stream, instrument_name, fields:
print(f"Update received for {instrument_name}: {fields}"))
pricing_stream.open()
Output:
Refresh received for EUR= : {'DSPLY_NAME': 'BARCLAYS LON', 'BID': 1.1635, 'ASK': 1.1639}
Refresh received for GBP= : {'DSPLY_NAME': 'NEDBANK LTD JHB', 'BID': 1.3803, 'ASK': 1.3807}
Refresh received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}
Refresh received for JPY= : {'DSPLY_NAME': 'ASANPACIFIBK MOW', 'BID': 113.81, 'ASK': 113.83}
Update received for JPY= : {'DSPLY_NAME': 'NEDBANK LTD JHB', 'BID': 113.81, 'ASK': 113.83}
Update received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}
Update received for JPY= : {'DSPLY_NAME': 'ASANPACIFIBK MOW', 'BID': 113.81, 'ASK': 113.83}
Update received for EUR= : {'DSPLY_NAME': 'BARCLAYS LON', 'BID': 1.1635, 'ASK': 1.1639}
Update received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}
Search
from lseg.data.content import search
response = search.Definition("IBM").get_data()
print(response.data.df)
RIC
BusinessEntity
PermID
DocumentTitle
PI
0
ORGANISATION
International Business Machines Corp, Public C...
37036
1
IBM
QUOTExEQUITY
55839165994
International Business Machines Corp, Ordinary...
1097326
2
ORGANISATION
Tiers Corporate Bond Backed Certificates Trust...
18062670
3
ORGANISATION
SG Stuttgart Vaihingen BM-Campus 1 UG haftungs...
27968389
4
0#IBMF:
QUOTExEQUITY
21481052421
Eurex International Business Machines Equity F...
48924732
5
0#IBMDF:
QUOTExEQUITY
21612423771
Euronext Amsterdam IBM Dividend Future Chain C...
259118763
6
IBMFc1
QUOTExEQUITY
21481052892
Eurex International Business Machines Equity F...
49450681
7
IBMFc2
QUOTExEQUITY
21481053949
Eurex International Business Machines Equity F...
50092347
8
IBMDFc1
QUOTExEQUITY
21613372305
Euronext Amsterdam IBM Single Stock Dividend F...
260213021
9
IBMFc3
QUOTExEQUITY
21481053950
Eurex International Business Machines Equity F...
50092348
Close the session
ld.close_session()
Learn more
To learn more about the LSEG Data Library for Python simply log into the LSEG Developer Community. By
registering and
logging in to the LSEG
Developer Community portal you will have free access to a number of
learning materials such as
Quick Start guides,
Tutorials,
Documentation
and much more.
Help and Support
If you have any questions regarding the API usage, please post them on
the Refinitiv Data Q&A Forum.
The LSEG Developer Community will be very pleased to help you.
Alternatives
Use instead of lseg-data: tools that do the same job, closest first.