Eikon Data API

API Family: Eikon APIs

Fundamentals API - Company Tearsheet Estimate

Download source code from

 
Last update January 2019
Interpreter Python 2.x/3.x

 

We would like to start this tutorial where Eikon Data API Quick Start guide has left off.  This brief tutorial will discuss the steps required to retrieve the data that is presented in the Estimates section of "Company Tearsheet" Eikon Excel example.

Prerequisites

  1. TR Eikon (version 4.0.36 or higher) or the Eikon Data API Proxy is installed
  2. Python is installed
  3. Eikon Data API Python library is installed

Please refer to Quick Start Guide to learn about the installation procedure.

    Expected Result

    This is how the Estimates look in Eikon Excel Company Tearsheet template example

    We learn how to retrieve the same data content via Eikon Data API from Python

    Approach (Detailed in the Next Sections)

    1. Using Eikon Excel for lookup.
    2. Using Data Item Browser (DIB) as reference.
    3. Using Eikon Data API Python library to access data.

    Using Excel for Lookup

    1. From All Programs menu, we expand Thomson Reuters menu item and select Thomson Reuters Eikon - Microsoft Excel.
    2. Once Excel is open, from Thomson Reuters menu item we choose "Sign In" option, and enter valid Thomson Reuters Eikon credentials, hitting "Sign In" button.  The status should change to "Online"

    1. Next, from Thomson Reuters ribbon, we choose Templates

    Select from the Template Library "Fundamentals" on the left, then "Company Tearsheet" on the right, then click "Open":

    1. We are looking at the example spreadsheet named "Company Tearsheet".  In this tutorial we will aim to replicate the data retrieval in Estimates parts of this example by using Eikon API from Python.  Let's start by clicking on the bottom tab "Company Tearsheet", while zeroing-in on the section "Estimates"

    1. Now we are ready for the most important step in the lookup.  As we click on one of the cells that contain functions retrieving estimates for the company, for example E24, in the Excel formula bar we see the function call that is required to pull this data:

    For example, E24 contains TR.RevenueHigh field name with parameters signifying forecast period of next year ("FY1"), scale of 6 or one million, and currency #1, referring to "USD".

    The repeated lookup will allow us to learn how Company Tearsheet example is built, down to every cell,  every function call complete with the required information.  These details we are going to use to call the same  functions from Eikon Python library.

    1. While we are still looking at Eikon Excel, let's step aside from Company Tearsheet Estimates example, and consider a generic approach to discovering Eikon data content.  We are are going to discuss using _Excel Formula Builder_.

      We click on an empty Excel cell and from ThomsonReuters menu we choose "Build Formula":

    Once Formula Builder is up, in the "Instrument" input we type "IBM" and out of the offered options click on "International Business Machines":

    Next, in "Search Data Items" input we type "Revenue High":

    Now from "Category" selection list we select "Reuters Fundamentals", from "Fields" selection list we pick "Total Revenue" and in "Parameter" on the right hand side we change "Financial Period" to "FY-1".

    Our selections are reflected in the ready to use formula in the bottom left corner.  Once we are satisfied with the inputs, we click on "Insert" button in the bottom right corner:

    And our Excel spreadsheet, in the selected cell, now reflects the updated Total Revenue:

    Using DIB as Reference

    Eikon Data Item Browser is a lookup tool that we can use as an alternative to Excel.  It is particularly useful for development on Linux and Mac, as it allows to avoid switching between Linux or Mac and Windows machines. Once we have started and signed into Eikon, we type "DIB" in the Eikon floating toolbar and click on the "Data Item Browser" menu item to start the DIB:

    Then, we use the DIB to search for instruments and field names.

    Let's look at the following example.

    For Instrument we enter "IBM", and choose "International Business Machines":

    In Data Item Name we look up TR.RevenueHigh,  so we start typing "TR.RevenueH" and once TR.RevenueHigh appears in the main window, we select it.  We are able to:  

    • Lookup the complete list of parameters with possible values (on the right side panel) 
    • Review the specific value we expect for IBM, on the main panel

     

    Using Eikon Python library to Access Data

    And now we proceed to the most interesting part.  We know the data items we would like to use by looking it up in Eikon Excel examples, and we can parametrize the data items per requirement, by looking up the data items in Data Item Browser.

    1. We start Python interpreter.  We will work on the python script in separate text editor, pasting and running the script into python interpreter when we are ready to test. 
    2. Let us flex our muscle by running the following little script:

    Note, please be careful of the spaces and tabs, as python requires them sctrictly observed.

    df, err = ek.get_data("IBM", ['TR.RevenueActValue(Period=FY0, Scale=6, Curn=USD)',
                        'TR.RevenueMeanEstimate(Period=FY1, Scale=6, Curn=USD)',
                        'TR.RevenueMeanEstimate(Period=FY2, Scale=6, Curn=USD)'])
    df

    We should see the output: 

    Instrument  Revenue - Actual  Revenue - Mean Estimate  \
     0        IBM             79919              78717.97129
    
       Revenue - Mean Estimate
     0              78663.43974
    1. Next we try to retrieve data for the three different periods, as required for Esimates in the Excel example spreadsheet, while laying the results out into rows:
    df1, err = ek.get_data("IBM", ['TR.RevenueActValue(Period=FY0, Scale=6, Curn=USD)',
                        'TR.RevenueMeanEstimate(Period=FY1, Scale=6, Curn=USD)',
                        'TR.RevenueMeanEstimate(Period=FY2, Scale=6, Curn=USD)'])
    
    df2, err = ek.get_data("IBM", ['TR.RevenueHigh(Period=FY1, Scale=6, Curn=USD)',
                        'TR.RevenueHigh(Period=FY2, Scale=6, Curn=USD)',
                        'TR.RevenueLow(Period=FY1, Scale=6, Curn=USD)',
                        'TR.RevenueLow(Period=FY2, Scale=6, Curn=USD)'])
    
    df3, err = ek.get_data("IBM", ['TR.RevenueLow(Period=FY1, Scale=6, Curn=USD)',
                        'TR.RevenueLow(Period=FY2, Scale=6, Curn=USD)'])
    
    df4, err = ek.get_data("IBM", ['TR.RevenueMeanEstimate(Period=FY1, RollPeriods=False, Scale=6, Curn=USD)',
                        'TR.RevenueMeanEstimate(Period=FY2, RollPeriods=False, Scale=6, Curn=USD)'])
    
    df1
    df2
    df3
    df4
    

    We see the output:

    >>> df1
      Instrument  Revenue - Actual  Revenue - Mean Estimate  \
     0        IBM             79919              78717.97129
    
       Revenue - Mean Estimate
     0              78663.43974
     >>> df2
      Instrument  Revenue - High  Revenue - High  Revenue - Low  Revenue - Low
     0        IBM           80564           81180          76706          76078
     >>> df3
      Instrument  Revenue - Low  Revenue - Low
     0        IBM          76706          76078
     >>> df4
      Instrument  Revenue - Mean Estimate  Revenue - Mean Estimate
     0        IBM              78717.97129              78663.43974
     >>>
    1. Now we are looking to retrieve the complete set of data required, while formatting the output into columns.

    Please refer to the complete script

     

    Note, that there can be only one request to get the field in get data call.  Therefore, for the same field call, but with different parameters, we use another call.

     

    When we run this script, the result should be:

    We'd like to conclude this tutorial by inviting you to experiment with both the tools and the approach.  Hope you will find the tools useful and approach working, but not set in stone.  We encourage you to share your results and successes, as well as your questions and problems with us on

    Q&A Forum