Eikon & Python: time series for EURO STOXX 50 index

Published on October 2nd, 2020

Are you using the Eikon API and Python? Then it is fairly easy to retrieve time series data for an index and its constituents. For example, you can use the following brief code snippet to download time series data for the Euro Stoxx 50.

"""
Example code to retrieve an index + constituents time series. 
Please define the following three variables
"""
import eikon
import datetime

# Your configuration
app_key = 'XXXXXXXXXXXXXXXXXXXX'   
index = 'STOXX50E'
number_of_days = 10


# Defines the index RIC and the index chain codes
index_RIC = '.' + index
index_chain = '0#.' + index

# Authenticate
eikon.set_app_id(app_key)

end = datetime.datetime.now()
start = end - datetime.timedelta(days=number_of_days)

# Read the index into empty dataframe
df_index = eikon.get_timeseries([index_RIC],
                                start_date=start,
                                end_date=end,
                                fields='CLOSE')

# Rename "CLOSE" column to the index name to prevent clash
df_index = df_index.rename(columns={'CLOSE': index_RIC})

# Read in more stocks
symbols = eikon.get_data(index_chain, 'TR.RIC')[0]['RIC']

for symbol in symbols:
    df_temp = eikon.get_timeseries([symbol],
                                   start_date=start,
                                   end_date=end,
                                   fields='CLOSE')
    # Rename to prevent clash
    df_temp = df_temp.rename(columns={'CLOSE': symbol})

    # Join the two dataframes
    df_index = df_index.join(df_temp[symbol])

# Show the output
print(df_index)

Conclusion: easy to get index data with Eikon & Python

This is just a small example of how you could use the Eikon API with Python. You can find the official documentation at https://developers.refinitiv.com/eikon-apis/eikon-data-api.  However, if you need any help with the Eikon API, I’ve worked at Refinitiv for 4 years. So please feel free to reach out.  Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.