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.

1 Answer

· Write an Answer
Upvotes
Accepted
86k 292 53 78

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