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?

Best Answer

  • 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)"

Answers

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



  • Both solutions work! Thank you so much!