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
5 1 4 8

Filter companies based on a compound keyword in the Business Description, using the Eikon API

I learnt how do it with simple keywords (single word) following this article: https://developers.refinitiv.com/en/article-catalog/article/find-your-right-companies-with-screener-eikon-data-apis-python.


But there is an issue when the keyword is compound (spelled with two different words). I will give an example to illustrate the issue. Applying the filters in the lower left (note the compound keyword "laser solutions"), I find one company shown in the image:

screen-shot-2022-01-21-at-71355-pm.png

Now in order to get SCREENER syntax, I press the little arrow next to the green excel button and select "Export All as Formulas".


This gives the following formula:

=TR("SCREEN(U(IN(Private(OrgType(COM, UNK, MKP)))/*UNV:Private*/), IN(TR.HQCountryCode,""GB""), IN(TR.TRBCEconSectorCode,""56""), IN(TR.TRBCIndustryCode,""56101010""), Contains(TR.BusinessSummary,""laser solutions""), CURN=USD,TR.Organizati"&"onStatusCode=Act)","TR.CommonName;TR.HeadquartersCountry;TR.TRBCEconomicSector;TR.TRBCIndustry;TR.BusinessSummary","curn=USD RH=In CH=Fd")


Now, following the steps in https://developers.refinitiv.com/en/article-catalog/article/find-your-right-companies-with-screener-eikon-data-apis-python, I extract SCREENER syntax and format it in Python:

syntax = "SCREEN(U(IN(Private(OrgType(COM, UNK, MKP)))), IN(TR.HQCountryCode,""GB""), IN(TR.TRBCEconSectorCode,""56""), IN(TR.TRBCIndustryCode,""56101010""), Contains(TR.BusinessSummary,""laser solutions""), CURN=USD, TR.OrganizationStatusCode=Act)"
    
fields = ["TR.CommonName","TR.HeadquartersCountry","TR.TRBCEconomicSector","TR.TRBCIndustry","TR.BusinessSummary"]

df, e = ek.get_data(syntax, fields)

But the df I get is:

screen-shot-2022-01-21-at-72651-pm.png

If everything was fine, I should have gotten the same company I get when I use the Refinitiv desktop. I noticed that if instead of using the compound keyword "laser solutions", I use the simple keyword "laser", I find the right company, i.e. I get the same result in the desktop and in my jupyter notebook.


How can I filter using the API, based a compound keyword, and get the same result as with the desktop?

eikoneikon-data-apipythonworkspaceworkspace-data-apidatarefinitiv-data-platform-eikon
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.

Upvote
Accepted
17.3k 82 39 63

Hi @bm01 ,

Try placing the embedded strings within your Screener expression as single quotes:

syntax = "SCREEN(U(IN(Private(OrgType(COM, UNK, MKP)))), IN(TR.HQCountryCode,'GB'), IN(TR.TRBCEconSectorCode,'56'), IN(TR.TRBCIndustryCode,'56101010'), Contains(TR.BusinessSummary,'laser solutions'), CURN=USD, TR.OrganizationStatusCode=Act)"
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.

Upvote
32.2k 40 11 20

Hello @bm01 ,

Try this:

syntax = "SCREEN(U(IN(Private(OrgType(COM, UNK, MKP)))), IN(TR.HQCountryCode,""GB""), IN(TR.TRBCEconSectorCode,""56""), IN(TR.TRBCIndustryCode,""56101010""), Contains(TR.BusinessSummary,""\"laser solutions\"""), CURN=USD, TR.OrganizationStatusCode=Act)"
    
fields = ["TR.CommonName","TR.HeadquartersCountry","TR.TRBCEconomicSector","TR.TRBCIndustry","TR.BusinessSummary"]
 
df, e = ek.get_data(syntax, fields)
df

from my testing, the result is:

escape.gif

not fully sure, the extra double-quote appears to help keep the expression together as it is passed from screen.




escape.gif (26.7 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.

Upvotes
5 1 4 8

Both solutions work! Thank you so much!

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.

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.