ARTICLE

Upgrade from using Eikon Data API to the Data library

Raksina Samasiri
Developer Advocate Developer Advocate

Introduction

Welcome to this article, we have something special to share with you who is interested in retrieving financial data programmatically with basic Python, including the current user of Eikon Data API. Let me introduce you to LSEG Data Library for Python, which can do everything that Eikon Data API does and even more. Especially, LSEG Data Library give you a possibility to connect to our server in different ways depending on what suit your workflow. This article will tell you all about this library and how it is the better choice. We are happy to share this journey with you and can’t wait for you to let it helps improving your workflow.

If you are familiar with the reason behind this upgrade, click here to go to the Upgrade Guide section

The Strategy

  • The Refinitiv Data Library (RD Lib) will be renamed the LSEG Data Library (LD Lib)
    Due to LSEG's acquisition of Refinitiv, Refinitiv products and libraries are rebranded as LSEG. Rebranding a library means changing its name, which is a breaking change. This change will occur in version 2.0 of our data library, which will by released by Q2 of 2024
  • We are taking advantage of the name change of our data library to slightly improve its public interfaces
    Some aspects of the public APIs will be slightly improved in the LSEG Data Library 2.0. The “eikon” module which is a duplicate of the Eikon library will be removed.
  • We will continue to support and maintain the Refinitiv 1.x data library
    After the rebranding and release of LSEG Data Library 2.0, the Refinitiv Data Library will become " Feature Complete", but we will continue to support it and provide maintenance releases. This is essential for customers who cannot migrate to the LSEG Data Library 2.0. However, new features will only be added to the LSEG data library.
  • The “eikon” module will not be removed from the Refinitiv 1.x data library
    The FutureWarning you noticed was about the change to the LSEG Data Library 2.0. Maintenance releases of RD Lib will continue to include the “eikon” module. There are no plans to remove it.
  • We will ensure that there are no dependency conflicts between the Eikon library, the Refinitiv data library and the LSEG data library
    This is essential for CodeBook and many of our customers. This check will be integrated into our automated tests.
  • The underlying data sources used by the LSEG Data Library's get_data() function will be fully aligned with those used by the Eikon Library's ek.get_data()
    This will ensure a smooth migration from the Eikon library to the LSEG Data Library.

Overview of Eikon Data API

Eikon Data API, the part of the Eikon suite that provides simple access to Eikon data, is an ease-of-use libraries provided in Python and R programming languages. However, the Eikon application or LSEG Workspace application is required to be running to use this API as the application integrates a Data API proxy that acts as an interface between the library and our data platform.
This library is "Feature Complete", but we continue to support it and provide maintenance releases.

Introduction to LSEG Data Library

Now, let’s talk about our newer and strategic library, LSEG Data Library for Python, which 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 our Data Platform. With this library, the similar Python code can be used to retrieve the same data with Eikon Data API, but with more options of session type that you can choose to connect to the Data Platform depending on the Credentials and Services you have access to, you need to define and open either a Platform Session or Desktop Session:

  • Platform Session: Used to connect to the Data Platform directly or via a local (deployed) Real-time Distribution System (RTDS). This requires our data platform credentials (machine account) or connection details of your local platform (IP of the local server and DACS username).
    • When the Platform Session is used with the Data Platform credentials only, it retrieves both streaming data and non-streaming data from the Data Platform.
    • When the Platform Session is used with connection details of your local deployed platform, it retrieves streaming data only from your local platform.
  • Desktop Session: Like a connection of Eikon Data API, this type of session is used to connect to the Data Platform either via Eikon or via the LSEG Workspace application. The application must be run on the same PC as your Python code.

To learn more about these sessions and their access credentials required, please check the quick start guide prior start using the library 

Plus, this library provides several abstraction layers enabling different programming styles and technics suitable for all developers from Financial Coders to Seasoned Developers:

  • Access layer: The easiest way to get Refinitiv data. It 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.
  • Content layer: 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.
  • Delivery layer: A low abstraction layer that defines interfaces used to interact with service agnostic delivery mechanisms of the Refinitiv Data Platform. The Delivery layer is a foundational component of the Content layer.
  • 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 Refinitiv Workspace, via CodeBook or even via a local Real-Time Distribution System).

Example codes of Python RD Library for these layers can be found here

In this article, we will focus on using the desktop session with access layer as you should have access to the LSEG’s RD Library desktop session if you have access to the Eikon Data API and the access layer is easiest to code.

Benefits

As we move from Eikon Data API to the Data Platform Library in Python, we are happy to let our users know how this change will be good for them. Here are some of the main benefits for existing Eikon Data API user to upgrade to the Data Platform Library.

  1. Easy changeover: We have made sure that upgrading to the new library will be easy, you won’t have to worry about big changes or difficulties.
  2. More value for you: With the new library, you get more than what you had with the previous one. This means more information, more ways to connect, etc.
  3. Customization to your needs: Every user’s workflow is different, and we know that. Hence, the new library lets you choose how you want to get data. This means you can set it up in a way that works best for you and your workflows.
  4. Real-Time Data: The new library also lets you see data as it happens. This is very important in the financial world where things change quickly.

We are really excited for you to experience the new library. It’s not just a new product but a big step forward in how we provide data and services to you.

Usage and Limits Guideline

If you are connecting using a desktop session to Eikon or Workspace via RD Library - the same limit as Eikon Data API applies - as the RD Library is mimicking the Eikon API and still sourcing its data from Eikon. We will keep you posted in case there is any update on this.

Upgrade guide

  • You can click the link on the first column to redirect to more detail section.
  • RD Library here refers to its Desktop session and Access layer.
  • Eikon Data API Python Library is currently available in the Refinitiv Data Python Library package, to import it, you can use refinitiv.data.eikon instead of eikon.
    • However, it will be removed in the future library version 2.0. Hence, you are recommended to upgrade your code to use the RD Library instead of Eikon Data API.
    • The "eikon" module of the Refinitiv Data Platform Library for Python embeds all functions of the classical Eikon Data API ("eikon" python library). This module works the same as the Eikon Data API and can be used by applications that need the best of the Eikon Data API while taking advantage of the latest features offered by the Refinitiv Data Platform Library for Python. 
Comparison topic Eikon Data API RD Library
Python library to import eikon or refinitiv.data.eikon refinitiv.data
  • Installation command
pip install eikon pip install refinitiv-data
  • Import command
import eikon as ek or
import refinitiv.data.eikon as ek
import refinitiv.data as rd
Available functions  

1 ) Make a connection

ek.set_app_key('EIKON_APP_KEY') rd.open_session(app_key = APP_KEY)

2) Get data

ek.get data() rd.get_data()

3) News

ek.get_news_headlines()
ek.get_news_story()
rd.news.get_headlines()
rd.news.get_story()

4) Convert symbology

ek.get_symbology() rd.convert_symbols()

5) Historical data

ek.get_timeseries() rd.get_history()

Available functions

1 ) Make a connection

Eikon Data API

The Eikon application or Workspace application must be running when you use the Eikon Data API Python library. Then generate the app key to be used with the set-app-key function. More detail can be found in the quick start guide.

    	
            

#import refinitiv.data.eikon as ek # eikon module in rd library

import eikon as ek

ek.set_app_key('EIKON_APP_KEY')

RD Library

When accessing content from the desktop, you should have already obtained a valid desktop login. Therefore, to access content using the libraries, you will need an App Key required for a Desktop Session or if you are running the Workspace/Eikon Desktop Application (on the machine where you run your code), this information will be retrieved from the desktop application.. You can also access content directly within the cloud utilizes the OAuth 2.0 specification to ensure secure communication to use the Platform Session, User ID/Machine ID, Password, App Key are required.

This library also comes with more flexible ways to set the configuration, more detail can be found in the quick start guide and article: LSEG’s Refinitiv Data Library for Python and its Configuration Process. Normally, the function below will be used.

    	
            

import refinitiv.data as rd

rd.open_session(app_key = APP_KEY)

2) Get data

Basically the function from two libraries are the same but for RD library fields parameter are not required (all available fields of instrument will be returned in the result if no field is specified). Plus, how their error returned are different as in Eikon Data API, the error will be returned as second variable of output, but for RD library, error will be raised as an exception.

Eikon Data API

    	
            get_data(instruments
    , fields
    , parameters=None
    , field_name=False
    , raw_output=False
    , debug=False)

RD Library

    	
            get_data(universe: Union[str, Iterable[str]]
    , fields: Union[str, Iterable[str], NoneType] = None
    , parameters: Union[str, dict, NoneType] = None
    , use_field_names_in_headers: bool = None)
  Eikon Data API RD Library
Function returns Returns a pandas.DataFrame with fields in columns and instruments as row index, and error message. Hence, the best practice on assigning the result of this function is assign it as a dataframe (pandas.DataFrame) and error (list of error)
Retrieves pricing snapshots, as well as Fundamental and Reference data as pandas.DataFrame. This function only return result as a pandas.Dataframe. It raises exceptions on error and when no data is available
  • Instrument ro request
instruments (mandatory) string or list universe (mandatory) string or list
  • Fields to request
fields (mandatory) string or list of strings fields (optional) string or list of strings
If no field is specified, all available fields on the instrument will be returned
  • Parameters
parameters (optional) string or dictionary - default None
Single key=value global parameter or dictionary of global parameters to request
  • Set field name
field_name (optional) boolean - default False
Define if column headers are filled with field name or display names.
use_field_names_in_headers (optional) boolean - default False
If True - returns field name as column headers for data instead of title
  • Get raw output
raw_output (optional) boolean - default False
By default the output is a pandas.DataFrame, set raw_output=True to get data in JSON format.
-
  • To debug
debug (optional) boolean - default False
When set to True, the JSON request and response are printed.
This can be set in the Configuration file, set logs.level to debug

3) News

Each libraries provide two functions to retrieve news, which are functions to retrieve news headlines and news story.

Eikon Data API

    	
            

get_news_headlines(query='Topic:TOPALL and Language:LEN'
    , count=10
    , date_from=None
    , date_to=None
    , raw_output=False
    , debug=False)

 

get_news_story(story_id
    , raw_output=False
    , debug=False)

RD Library

    	
            

get_headlines(query: str
    , count: int = 10
    , start: 'OptDateTime' = None
    , end: 'OptDateTime' = None
    , order_by: Union[str, refinitiv.data.content.news.headlines._sort_order.SortOrder] = <SortOrder.new_to_old: 'newToOld'>)

 

get_story(story_id: str
    , format: Union[refinitiv.data._access_layer.news._news.Format, str] = <Format.HTML: 'Html'>)

3.1 ) To get news headlines

  Eikon Data API RD Library
Function to get news headlines ek.get_news_headlines()
rd.news.get_headlines()
Function returns A dataframe of related news headlines
  • Query
query (optional) string
News headlines search criteria.
query (mandatory) string
The user search query for news headlines.
  • Count
count (optional) int - Default: 10 
Max number of headlines retrieved. Value Range: [1-100], Count to limit number of headlines.
  • Start date of news
date_from (optional) string or datetime
start (optional) string or timedelta
Beginning of date range.
String format is: '%Y-%m-%dT%H:%M:%S'. e.g. '2016-01-20T15:04:05'.
  • End date of news
date_to (optional) string or datetime
end (optional) string or timedelta
End of date range.
String format is: '%Y-%m-%dT%H:%M:%S'. e.g. '2016-01-20T15:04:05'.
  • other parameters
  • repository (optional) string, list of strings
    Possible values: NewsWire, NewsRoom, WebNews
  • raw_output (optional) boolean - Default: False
    Set this parameter to True to get the data in json format
  • debug (optional) boolean - Default: False
    When set to True, the json request and response are printed.
  • order_by: string or SortOrder
    Sort order for headline items.

3.2) To get news story

  Eikon Data API RD Library
Function to get news story ek.get_news_story() rd.news.get_story()
Function returns Return a single news story corresponding to the identifier provided in story_id as HTML text Retrieves the news story items as string
Parameters get_news_story(story_id, raw_output=False, debug=False) get_story(story_id: str, format: Union[refinitiv.data._fin_coder_layer.news._news.Format, str, NoneType] = <Format.HTML: 'Html'>)
  • Story ID
story_id: string
The story id is a field you will find in every headline you retrieved with getting news headlines
  • Other parameters
  • raw_output: boolean - Default: False
    Set this parameter to True to get the data in json format
  • debug: boolean - Default: False
    When set to True, the json request and response are printed
  • format (optional) string or Format
    Response format.

4) Convert symbology

The function name and how to apply parameters are different between two libraries

Eikon Data API

    	
            get_symbology(symbol
    , from_symbol_type='RIC'
    , to_symbol_type=None
    , raw_output=False
    , debug=False
    , best_match=True)

RD Library

    	
            convert_symbols(symbols: 'StrStrings'
    , from_symbol_type: Union[str, ForwardRef('SymbolTypes')] = '_AllUnique'
    , to_symbol_types: 'SymbolTypesType' = (<SymbolTypes.RIC: 'RIC'>, <SymbolTypes.ISIN: 'IssueISIN'>, <SymbolTypes.CUSIP: 'CUSIP'>, <SymbolTypes.SEDOL: 'SEDOL'>, <SymbolTypes.TICKER_SYMBOL: 'TickerSymbol'>, <SymbolTypes.OA_PERM_ID: 'IssuerOAPermID'>, <SymbolTypes.LIPPER_ID: 'FundClassLipperID'>)
     ,preferred_country_code: 'OptCountryCode' = None
    , asset_class: 'OptAssetClass' = None
    , asset_state: 'OptAssetState' = None)
  Eikon Data API RD Library
Function to convert symbology ek.get_symbology()
rd.convert_symbols()
Function returns Returns a pandas.DataFrame of instrument names converted into another instrument code.
  • Instrument
symbol: string or list of strings symbols: string or list of strings
This is the only mandatory parameter, other parameters are optional
  • From symbol type
default: RIC default: _AllUnique
from_symbol_type: string - Instrument code to convert from.
Possible values: CUSIP, ISIN, SEDOL, RIC, ticker, lipperID, IMO
  • To symbol type
to_symbol_type: string or list of strings to_symbol_type: string or list of strings or SymbolTypes
Instrument code to convert to - Default: all symbol types are requested
Possible values: CUSIP, ISIN, SEDOL, RIC, ticker, lipperID, IMO, OAPermID
  • Other parameters
  • raw_output: boolean - default False
    Set this parameter to True to get the data in json format
  • debug: boolean - default False
    When set to True, the json request and response are printed
  • best_match: boolean - default True
    When set to True, only primary symbol is requested.
    When set to false, all symbols are requested
  • preferred_country_code: string or CountryCode
    Unique ISO 3166 code for country
  • asset_class: string or AssetClass
    AssetClass value to build filter parameter
  • asset_state: string or AssetState
    AssetState value to build filter parameter

5) Historical data

For RD library rd.get_history, fields parameter are not required, all available historical fields of instrument will be returned in the result if no field is specified. While the ek.get_timeseries retrieves data only from the default view and map them to OPEN, HIGH, LOW, and CLOSE fields.

Eikon Data API

    	
            get_timeseries(rics
    , fields=None
    , start_date=None
    , end_date=None
    , interval=None
    , count=None
    , calendar=None
    , corax=None
    , normalize=False
    , raw_output=False
    , debug=False)

RD Library

    	
            get_history(universe: Union[str, Iterable[str]]
    , fields: Union[str, Iterable[str], NoneType] = None
    , interval: Optional[str] = None
    , start: 'OptDateTime' = None
    , end: 'OptDateTime' = None
    , adjustments: Optional[str] = None
    , count: Optional[int] = None
    , use_field_names_in_headers: bool = None
    , parameters: Union[str, dict, NoneType] = None)
  Eikon Data API RD Library
Function to get historical data ek.get_timeseries()
rd.get_history()
Function returns Returns a pandas.DataFrame of historical data on one or several instruments. It raises exceptions on error and when no data is available
  • Instrument
rics: string or list of strings universe: string or list of string
Instruments (mandatory) string or list of RICs to retrieve historical data for
This is the only mandatory parameter, other parameters are optional
  • Start date

start_date: string or datetime.datetime or datetime.timedelta

start: string or date or datetime or timedelta

  • String expressed in ISO8601 with UTC only
  • End date

end_date: string or datetime.datetime or datetime.timedelta

end: string or date or datetime or timedelta

  • String expressed in ISO8601 with UTC only
  • Interval

interval: string

  • Possible values: tick, minute, hour, daily, weekly, monthly, quarterly, yearly (Default is 'daily')
interval: string
  • Supported values: tick, tas, taq, minute, 1min, 5min, 10min, 30min, 60min, hourly, 1h, daily, 1d, 1D, 7D, 7d, weekly, 1W, monthly, 1M, quarterly, 3M, 6M, yearly, 1Y
  • Fields
field: string or list of strings
  • By default all available fields are returned (TIMESTAMP, VALUE, VOLUME, HIGH, LOW, OPEN, CLOSE, COUNT)

field: string or list of string to request

  • By default all available historical fields of instrument will be returned
  • Count
count: int
Max number of data points retrieved.
count: int
The maximum number of data points returned.
Values range: 1 - 10000.
Applies only to pricing fields.
  • CORAX (Corporate Actions)
corax: string
  • Possible values: adjusted, unadjusted

adjustments: string
Tells the system whether to apply or not apply CORAX (Corporate Actions)
events or exchange/manual corrections or price and volume adjustment
according to trade/quote qualifier summarization actions to historical time
series data.

  • Possible values:
    exchangeCorrection, manualCorrection, CCH, CRE, RTS, RPO, unadjusted,
    qualifiers
  • Calendar

calendar: string

  • Possible values: native, tradingdays, calendardays

parameters: string or dict
Single global parameter key=value or dictionary of global parameters to request.
Applies only to TR fields.

  • Normalize
normalize: boolean - default False
If set to True, the function will return a normalized data frame with the following columns Date, Security, Field
  • Get raw output
raw_output: boolean - default False
Set this parameter to True to get the data in json format
-
  • To debug
debug: boolean - default False
When set to True, the json request and response are printed.
This can be set in the Configuration file, set logs.level to debug
  • Show field name as a column header
- use_field_names_in_headers : bool, default False
If True - returns field name as column headers for data instead of title

There are also other functions available such as getting streaming pricing data and other utility function such as chain object.

More details with the full example codes, including other layers (access, content, delivery, and session layer), can be found in the Example Repository

Conclusion

As we are upgrading to the new library, we want to thank our users for being part of this exciting journey. The new library is not just an upgrade but a big step forward in how we provide financial data and services. You will enjoy more flexibility, better data access, and the ability to see real-time information. We believe these changes are going to help you in working with the data more easily and flexibility.

Remember that we are here to support you. If you have any question or need any help regarding upgrading to the new library, you can find an answer in existing questions or post your question in our Q&A forum (with the tag: workspace-upgrade), the fastest way to get help from our experts, all questions in this forum are constantly monitored and answered by our developers and subject matter experts. We look forward to seeing how the new library will bring positive changes to your experience with our services.

Thank you for reading this article, we are excited about the future and can’t wait to share this next chapter with you.

  • Register or Log in to applaud this article
  • Let the author know how much this article helped you
If you require assistance, please contact us here