How can i get all companies listed in any exchange for a period?

I am using both refinitiv web and plug-in in Excel.

I would like to get all listed companies in London Business Exchange between 2005 and 2020 (active, inactive… everything)

Thanks in advance!!

Best Answer

  • m.bunkowski
    Answer ✓

    Hi @uva60

    You can try with the below code to use the search capability and retrieve equites listed on a selected exchange. There is no flag for a listing time window but if you need that you can e.g. check the timeseries to see if any datapoint was available for the defined period.

    import refinitiv.data as rd
    from refinitiv.data.content import search
    import pandas as pd
    rd.open_session()

    result_df = pd.DataFrame()

    custom_search = f"SearchAllCategoryv2 eq 'Equities' and ExchangeCode eq 'LSE'"

    #use navigators functionality to sort the number of expected results that each bucket contains less than 10k (search limit)
    #we use NameLength parameter that is applicable for all the instruments

    response=search.Definition(
    view = search.Views.EQUITY_QUOTES,
    filter = f'{custom_search}',
    top = 0,
    navigators = "NameLength(buckets:10)"
    ).get_data()

    navigators = response.data.raw['Navigators']['NameLength']['Buckets']

    #sample output:
    # [{'Label': 'Below 10',
    # 'Filter': 'NameLength lt 10',
    # 'Count': 4606},
    # {'Label': 'Between 10 And 12',
    # 'Filter': '(NameLength ge 10 and NameLength lt 12)',
    # 'Count': 6315},
    # {'Label': 'Between 12 And 14',
    # 'Filter': '(NameLength ge 12 and NameLength lt 14)',
    # 'Count': 6904},


    #iterate over navigators and merge the filter syntax with previous custom search syntax
    for n in navigators:
    sub_response = search.Definition(
    view = search.Views.EQUITY_QUOTES,
    filter = f"{custom_search} and {n['Filter']}",
    select = "IssuerLegalName,ExchangeName,RIC,IssueISIN",
    top=10000).get_data()

    #concatenate results
    result_df = pd.concat([result_df, sub_response.data.df])

Answers