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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
18 2 0 5

Hello , How to get S&P500 all stock daily weight by eikon with python API ? thank you.

Hello , How to get S&P500 all stock historical daily data and weight by eikon with python API ? thank you.

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonhistorical
icon clock
10 |1500

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

Upvotes
Accepted
18k 21 12 20

Hi @ethan.hayashi

You can follow this code to get S&P500 RIC list and get historical data:

(Because the get_timeseries accept up to 300 RIC so I have to split the list into 2 lists before calling the API)

As for weight, I do not understand the content you are trying to retrieve, please clarify or show me the sample data on the Eikon Desktop. I will try to see if it is accessible from API and will share the result.

Thanks.


ahs.png (56.6 KiB)
icon clock
10 |1500

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

Upvote
18k 21 12 20

I would like to share some idea to calculate weight.

1. Get all constituents

2. Get individual market cap

3. Sum market cap

4. calculate weight for each individual stocks against total market cap.

This is example code:


ahs.png (47.0 KiB)
icon clock
10 |1500

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

Hi @chavalit.jintamalit,

Thank you for your share .

One more question.

How can I add "date" everyday data , Thank you.

[Instrument] [DSPLY_NAME] [DATE] [Company Market Cap] [Weight]

========================================================

MSFT.OQ MICROSOFT CP/d 2019-08-29 1.0546e+12 3.946080310382849

You can add TR.CompanyMarketCap.Date field.

df,e = ek.get_data('0#.SPX',['DSPLY_NAME','TR.CompanyMarketCap','TR.CompanyMarketCap.Date'])
df

Hi Chavalit

Thank you so much.

Show more comments
Click below to post an Idea Post Idea