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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
13 2 2 6

Screener sort and top results

Hi all,

Is there any way to extract the top10 companies by Revenue in a specific TRBC activity using the screen expression in the Eikon API?

I mean, to the following query:

exp = 'SCREEN(U(IN(Equity(active, public, private, primary))),IN(TR.TRBCActivityCode,"5430102012"),CURN=USD)'

companies_data, err = ek.get_data(instruments=[exp], fields=['TR.Orgidcode','TR.CompanyName', {'TR.Revenue':{'params':{'Period': 'FY2016', 'Curn':'USD'}}}]

I only want to see the top10. Anyway, I think that Eikon can only return some x values.

Thanks in advance,

Miriam

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonscreeningscreener
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
3.8k 4 4 6

Hi @miriam.benito

You can include top 10 criteria directly in your screener expression

exp = 'SCREEN(U(IN(Equity(active, public, primary))),IN(TR.TRBCActivityCode,"5430102012"),TOP(TR.Revenue(FY2016), 10, nnumber),CURN=USD)'
companies_data, err = ek.get_data(instruments=[exp], fields=['TR.Orgidcode','TR.CompanyName', {'TR.Revenue':{'params':{'Period': 'FY2016', 'Curn':'USD'}}}])
companies_data.sort_values(by=['Revenue'],ascending=False)

I have done it only for public companies, the separate can be done for private ones.

This is how you can do it in in SCREENER


revenue.jpg (131.8 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.

@marcin.bunkowski, I converted your comment to an answer, it is the best answer to this query :-)

Upvotes
13.7k 26 8 12

@miriam.benito,

I do not know if there is a way to easily limit the result set to 10, I searched but could not find it. But there is a way to sort the results by revenue, using 'sort_dir':'desc'. This results in >76k results. A trivial solution to display only 10 results is to use head(10):

exp = 'SCREEN(U(IN(Equity(active, public, private, primary))),IN(TR.TRBCActivityCode,"5430102012"),CURN=USD)'
companies_data, err = ek.get_data(instruments=[exp], fields=['TR.Orgidcode','TR.CompanyName', {'TR.Revenue':{'params':{'Period': 'FY2016', 'Curn':'USD'}, 'sort_dir':'desc'}}])
companies_data.head(10)

Hope this helps a bit.

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 @Christiaan Meihsl,

Thanks for the help but if I run your code I have the error...:

EikonError: Error code 400 | Backend error. 400 Bad Request

I suppose that it is due to the Eikon limit per time.

I do not know if there is one way to sort the companies and only ask for top 10 ...

@miriam.benito,

A 400 is returned when the platform is overwhelmed. Not really surprising since there are >76k results.

I do not believe it is possible to limit the result set to only 10 directly, because the query is done in 2 steps:

  • the screener returns 76k instruments, based on your criteria,
  • these instruments serve as input to get_data, which retrieves the revenue for all input instruments.

You might want to narrow down your screening criteria, if possible.

An alternative could be to split the screener result set into several smaller ones, and submit several get_data requests for the smaller instrument lists. After that you could combine the individual result sets to analyze them. More cumbersome, but less heavy.

Upvotes
13 2 2 6

Hi @marcin.bunkowski and @Christiaan Meihsl

Thanks both for the help!!!

It works for public companies but I cannot get it right for private companies. I mean, for example Mercadona is not an equity and I want companies.

If I look for the formula in Eikon Excel there is no 'TOP' filter and when I write the formula in EIKON Python I get an error:

exp ="SCREEN(U(IN(Private(OrgType(COM, UNK, MKP)))/*UNV:Private*/), IN(TR.TRBCActivityCode,""5430102012""), BETWEEN(TR.PCTotRevenueFromBizActv(Period=FY2016), 0.00, 100.00), CURN=USD)" companies_data, err = ek.get_data(instruments=[exp], fields=['TR.CommonName'])

EikonError: Error code 400 | Backend error. 400 Bad Request

Thanks in advance,

Miriam


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
13.7k 26 8 12

@miriam.benito,

You might want to try this (thanks go to @marcin.bunkowski for help on this):

exp ="SCREEN(U(IN(Private(OrgType(COM,UNK,MKP)))/*UNV:Private*/), IN(TR.TRBCActivityCode,""5430102012""), TOP(TR.PCTotRevenueFromBizActv(Period=FY2016),10,nnumber), CURN=USD)"
companies_data, err = ek.get_data(instruments=[exp], fields=['TR.PCTotRevenueFromBizActv','TR.CommonName'])
companies_data.sort_values(by=['Total Revenue (Pvt)'], ascending=False)

Hope this helps

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.

Click below to post an Idea Post Idea