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
Best Answer
-
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
2
Answers
-
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.
0 -
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 ...
0 -
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.
0 -
marcin.bunkowski, I converted your comment to an answer, it is the best answer to this query :-)
0 -
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
0 -
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
1
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 370 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛