Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 1 1 2

How to use get_data with RIC, date combinations?

Hi all,

I imported a dataframe with RICs and dates. Now I would like to use get_data to retrieve market capitalization for all RICs at the specific dates. Is that possible with python eikon api?

Dataframe looks like this:

I tried the following :

idfy = pd.read_csv(\distcompfy.csv', encoding='utf-8')
mc, err =ek.get_data(list(idfy['RIC']), fields = ['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value' ] , parameters={'Scale': 6, 'Curn': 'USD', 'SDate': list(idfy['date'])})

But Python returns: "Error code 400 | Backend error. 400 Bad Request"

Is there a way to retrieve the data?

Best

Simon

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apidatatime-series
dataframe.jpg (27.2 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.

1 Answer

· Write an Answer
Upvotes
Accepted
18.2k 21 13 21

Hi @sile

The problem is on the list of date in parameters.

You cannot make a request with SDate as a list.

If you want a range of date, you can follow this request.

But if you want a specific date not in range, you have to separate your request.


sz.png (21.8 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.

To add to the answer by @chavalit.jintamalit, to specify the frequency of the series you can add Frq parameter to the request. E.g. to retrieve annual series of market cap values you can use

ek.get_data('000002.SZ', 
    ['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value'], 
    {'Scale': 6, 'Curn': 'USD', 
    'SDate': '20160101', 'EDate': '20190101', 'Frq':'FY'})

Thank you both. That's helpful. I already implemented my code as in @Alex Putkov. response. However, the problem here is that Fiscal Year Ends depend on the company. The FY of some companies' ends e.g., in March.

My dataframe includes all RICs with the correspondinf FY end over the period from 1999-2017.

Now I use the following loop, however it takes really long:

Do you have a recommendation how to speed it up, or an alternative way to cope with the FY end problem?

rics = list(idfy.RIC.values)
dates = list(idfy.date.values)
mc = {}
for x in range(0,10000,1):
    mc[x], err =ek.get_data(rics[x], fields = ['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value' ] , parameters={'Scale': 6, 'Curn': 'USD', 'SDate': dates[x]})

You could maybe group your stocks by fiscal year end date and retrieve market cap for multiple stocks that have the same fiscal year end date in a single request. This is the only optimization I can think of.

Show more comments

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.