New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
Accepted
2 1 1 5

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

· Write an Answer
Upvotes
Accepted
32.2k 41 11 20

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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