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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles


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



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

18.1k 21 12 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

    ['', '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(
mc = {}
for x in range(0,10000,1):
    mc[x], err =ek.get_data(rics[x], fields = ['', '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