Article

Eikon Excel Company Tearsheet in Python (Part 2)

    Zoya Farberov
    Developer Advocate

Introduction

This is the second part of Eikon Excel Company Tearsheet in Python article.  It picks up the discussion right where Eikon Excel Company Tearsheet in Python Part 1 left off, and continues with going over Charting.  For the best understanding of the material being presented, we suggest reading Part 1 first, by following this link.

Simple Charting with Eikon Data

Many of Eikon Data API charting requirements can be met by retrieving the content via API calls into Dataframes and charting it.  An example of this use case is

Stock Performance Chart that uses Price Actions content.

1. We retrieve the content via Eikon Data API

2. Next we populate the results into lists so that the first list contains names and the second contains values, in this case, price actions, removing the head of the list, RIC

3. Multi-Row Dataframe in convinently structured via Dictionary:

4. Next we chart it using Plotly library:

Find more info on Plotly charting in References section.

One feature that we find particularly useful for charting in Jupyter notebook, is offline charting:

Advanced Charting with Eikon Data

The above approach is single-pass:  all of the required data points are obtained via Eikon Data API and fed directly into a chart such as plotly chart, with minimal transformations required, and simple massaging can be done in-place. 

Some Eikon data charting requirements cannot be met via this approach.   One or more of the intermediate data sets are required to derive the complete data set that is required for charting.  These requirements can be met via multi-pass approach.

Price Chart, at the bottom of Company Tearsheet Template, is a good example of this type of requirement.  In Eikon Excel this requirement is also implemented as a multi-pass, and we follow the same approach.

We review how this is done with Eikon Excel to better understand the approach, and then we translate it into Python.  The approach selected for Price Chart implementation may not be the only possible, we aim to keep the approach in Python consistent with the approach selected for Price Chart in Excel template, so the two are in synch.

Let us get started.

1. Tab Data of Company Tearsheet Template is where Data transformations are performed. First, prices are retrieved into columns R and S

Similarly, in py's section Pricing Data 1 - Closing Prices we retreive the same closing prices

2. Next in columns O and P, a set of MSFT closing dates is retreived (based on the prices previously retreived into columns R and S)

And the two dates, that constitute the edges of the interval, are derived from them: 

The sa is done in py, in section Pricing Data - 2 - Dates, we do the same (defining a function to determine the number of workdays between dates):

3.  Now we use the dates to retrieve the data sets that we require for charting.

In Excel it is done this way:

While calculating 50 and 200 day moving average

Note the references to columns O and P where the border dates were calculated.

 

And in Python Pricing Data - 3 - Volumes, Prices, 50 days, 200 days section:

and note the use of numpy.convolve described in more detail in References to conveniently obtain the required running averages .

The third step completes the chart data requirement and we are ready to pass the data into plotly chart:

There are two features of the resulting chart that may be worth noting:

  • It is made more meaningful by the fact that it carries two Y axes, one for Prices and one for Volumes
  • We cut off the data in all the charted Dataframes at desired point, prior to passing it into go.Scatter, allowing us to present only  the most meaning portion of the data set.

We hope that this article helps our reader to reproduce Eikon Excel Company Tearsheet example in Python, and, Jupyter notebook: that accompanying downloadable code  on GitHub contains ready-to-use examples that may be relevant, and that at least some of the approaches discussed can be re-used for the next Eikon Data API tasks and projects.