For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
2 0 0 1

Index Constituents - Start of every year with Market Cap

Hi

I want to get the index constituents of the .TRXFLDINP index from the start of every years since 2012, along with the Market Cap and Average Value Traded (so Volume x Price) at the start of every year.

I have gone through some of the questions posted but do not find the solution I am looking for.

Thanks

pythonrefinitiv-dataplatform-eikon#technologyconstituents
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvotes
Accepted
32.2k 40 11 19

Hi @vbala ,

I would try to divide the task:

  1. Compile the list of dates at the beginning of the year
  2. Request the list of constituents
  3. Request the market caps and average values traded

Try this, and you may wish to tune the approach on your side to your requirements:

import datetime
for year in range(2012, 2022):
    sdate_for_year = str(year)+'-01-01'
    print("sdate ", year, " = ", sdate_for_year)
    
    df, err = ek.get_data(
        instruments = ['.TRXFLDINP'],
        fields = ['TR.IndexConstituentRIC',
                  'TR.IndexConstituentName'],
        parameters = {
            'SDate':sdate_for_year
        }
    )
    print('Constituents:')
    print(df)
    
    df2, err = ek.get_data(
        instruments = df['Constituent RIC'].tolist(),
        fields = ['TR.CompanyMarketCap',
                  'TR.AvgMonthlyValTraded1Year'],
        parameters = {
            'SDate': sdate_for_year
        }
    )
    print(df2)

This results in the output:

mcapout.gif

Hope that this suggestion is of help



mcapout.gif (76.7 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you