Export Query in advanced Search

Midas
Midas Newcomer

To add Return on Investment (ROI) or Earnings Before Interest and Taxes (EBIT) in Advanced Search, follow these steps:

1. Open Advanced Search.

2. Select a universe (e.g., Equities).

3. In the Results panel, click "Add Additional Fields".

4. In the Data Item Library, select a category (e.g., Financials) and choose the desired field (e.g., ROI or EBIT).

These fields will be added as temporary columns to your search results table.

If I follow these steps, there is nothing added in the export query. If I add another column like Revenue USD, it's also selected in the export query (code).

How can I access these additional Fields in the export query?

Answers

  • Hi @Midas ,

    Sorry for an inconvenient, this is the behavior of Export Query in Advanced Search application that the selected fields will not be exported along with filters (However, our product team also would like to make it export selected fields in the future, will keep you updated)

    As an alternative, from the output of Search function, RICs list can be used to retrieve the data with get_data() function. Fields or Data Item name can be found in CodeCreator application inside Workspace.

    image.png

    The code below can be used

    import lseg.data as ld
    ld.open_session() search_df = ld.discovery.search(
    view = xxxxxx
    ,
    filter = "xxxxxx",
    select = "xxxxxx"

    ) rics_list = search_df['RIC'].to_list()

    df = ld.get_data(
    universe = rics_list,
    fields = [
    'TR.PCReturnOnInvestedCapPct',
    'TR.EBITMean'
    ]
    )
    display(df)
  • Midas
    Midas Newcomer

    import lseg.data as ld

    ld.open_session()

    Perform a free-text search for instruments related to the "Consumer Discretionary" sector

    search_df = ld.discovery.search(
    view="EquityQuotes", # Use the EquityQuotes view to get quote-level data
    query="Consumer Discretionary", # Search for the term "Consumer Discretionary"
    select="RIC" # Retrieve only the RICs (Reuters Instrument Codes)
    )

    #Extract a clean list of unique RICs (instrument identifiers)

    rics_list = search_df['RIC'].dropna().unique().tolist()

    #Request EBIT estimate data (mean) for the identified instruments

    df = ld.get_data(
    universe=rics_list, # The list of instruments to request data for
    fields=['TR.EBITMean'] # Request the TR.EBITMean field (mean EBIT estimate)
    )

    #Remove entries where EBIT is missing or not available

    df = df[df['TR.EBITMean'].notna()]

    #Calculate the average EBIT across all valid instruments

    average_ebit = df['TR.EBITMean'].mean()

    #Print the final result

    print("Average EBIT in the Consumer Discretionary sector:", average_ebit)

    this is what I am aiming for… so the problem with your idea is, filtering out all the data. It was easily possible with advanced search but there was the error with the export query. Can you tell me what to do to access the necessary data for those average calculations?
    Thanks

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Midas

    The correct one could be:

    df = ld.discovery.search(
        view = ld.discovery.Views.EQUITY_QUOTES,
        filter = "Gics eq 'Consumer Discretionary'",
        select="RIC,Gics",
        top = 10000
    )
        
    df
    

    However, although approximately 168,297 entries match the filter, the search API can return only up to 10,000 entries.

  • Midas
    Midas Newcomer

    • The screen returns more than 5,000 results, please add more filters.

    the screener is limited to 5000