[Python API] How to fuzzy search for companies by name ?

Hi, thanks for taking a look. See subj.
Ideally, search would retrieve top N entries.
Even better, it would let me constrain the search scope to companies that are registered in a given country (precise match by code), operate in a given industry sector (either precise match by a symbology or a fuzzy one given keywords or a precise match against a list of options ("contains")) and / or have turnover (or other financials) in a given range -- and still return top N of those satisfying the constraints.
How can that be achieved using the Python API ?
Thanks in advance!
Best Answer
-
Fuzzy search is not available in Eikon. You can however combine exact string match name search with other criteria in Eikon Screener. Here's an example returning public companies containing the word "resources" in the company name, headquartered in the US and falling under Financials sector according to Thomson Reuters Business Classification scheme (TRBC).
name = '"resources"'
To construct Screener expression follow the wizard behind Screener button under Thomson Reuters tab in Excel ribbon. You may also want to watch a series of short video tutorials titled "Working with the Screener" available from the main Eikon menu - Help - Tutorials and Training. Type in "Screener" in the search bar a click on "Working with the Screener" in the results.
exp = ('SCREEN(U(IN(Equity(active,public,primary))),' +
' Contains(TR.CommonName,%s),' %name +
'IN(TR.HQCountryCode,"US"),' +
'IN(TR.TRBCEconSectorCode,"55"))')
fields = ['TR.CompanyName']
ek.get_data(exp, fields)
0
Answers
-
This question is similar, but the answers do not cover fuzzy matching and constraints:
0 -
Thanks, Alex. Are there boolean operators that can be used in conjunction with Contains?
Imagine there is a complex names with multiple words which may be in different forms including abbreviations. One way to search for such an entry would be to split it into words or ngrams, potentially, at character level, and use AND and OR to build up query expression.
For example:
OR(
AND(
Contains(..., "that-co"),
Contains(..., "inc")
),
AND(
Contains(..., "that"),
Contains(..., "company"),
Contains("incorporated")
)
)0 -
Follow the Screener wizard launched through Screener button in Excel ribbon to learn what is and isn't possible through the Screener. Once you set up your criteria in the Screener wizard click Insert Screen button to paste the formula into Excel worksheet. The screener expression in the first argument of the resulting =TR worksheet function can be copied & pasted into Python script with minor modifications related to syntactical differences in string manipulations between Excel formulas and Python.
It is possible to use logical expressions with multiple keywords and Contains statement and TR.CommonName field:exp = ('SCREEN(U(IN(Equity(active,public,primary))),' +
' (Contains(TR.CommonName,"resources") OR' +
' Contains(TR.CommonName,"energy") AND' +
' Contains(TR.CommonName,"Corp")),'
' IN(TR.HQCountryCode,"US"))')
fields = ['TR.CompanyName']
ek.get_data(exp, fields)0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 33 Data Model Discovery
- 682 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.8K Refinitiv Data Platform
- 625 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 83 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛