question

Upvotes
Accepted
1 0 1 1

Extract weights of index constituents using DataStream API/DSWS Wrapper on Python

How do I fetch the weights of each constituent of an index e.g. S&P500.

I can get the list of constituents as seen in this thread, but I cannot find a field corresponding to weight:

https://community.developers.refinitiv.com/questions/83971/can-i-use-datastream-api-dsws-to-collect-historica.html


pythondatastream
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.

@prakhar

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

1 Answer

· Write an Answer
Upvotes
Accepted
78.9k 250 52 74

@prakhar

You can use the WTIDX data type that represents "% Weight Of Each Constituent Within The List". You can access Datastream Navigator to search for instruments and data types.

The code looks like this:

df = ds.get_data("LFTSE100|L",['MNEM','WTIDX'], kind=0)
df.pivot(index='Instrument', columns='Datatype')['Value']

The output is:

1654573881632.png


1654573881632.png (12.3 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.

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.