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
1 0 0 1

From FundCompany to LEI

I post the following code. I am retrieving info starting from ISIN codes and I want to retrieve FundCompany and LEI code. To do that I first retrieve the RIC code, then fetch fund company and from here I look for the LEI.

The problem is that using the FundCompany retrieved from Refinitiv, the API can never find the LEI code and the column is a bunch of 'None' values. What is the problem here?


Thanks




# Iterate through RICs
for ric in rics_list:
try:
data_response, err = ek.get_data(ric,
fields=['TR.FundLegalStructure', 'TR.FundType', 'TR.FundCompany', 'TR.LegalEntityIdentifier'])
except Exception as e:
print(f"Error fetching data for RIC {ric}: {e}")
continue

if not err:
# Check if 'TR.FundLegalStructure' field exists in the data_response
fund_legal_structure = data_response['Legal Structure'].iloc[0] if 'Legal Structure' in data_response.columns else None

# Check if 'TR.FundType' field exists in the data_response
fund_type = data_response['Fund Type'].iloc[0] if 'Fund Type' in data_response.columns else None

# Check if 'TR.FundCompany' field exists in the data_response
fund_company = data_response['Fund Company'].iloc[0] if 'Fund Company' in data_response.columns else None

# Initialize LEI as None
lei = None

if fund_company is not None:
print(fund_company)

try:
# Fetch the LEI using the Fund Company
lei_response, lei_err = ek.get_data(fund_company.upper(), fields= ['TR.LegalEntityIdentifier'])
if not lei_err:
if 'Legal Entity Identifier' in lei_response.columns:
lei = lei_response['Legal Entity Identifier'].iloc[0]
else:
print(f"LEI data not found for Fund Company {fund_company}")
except Exception as e:
print(f"Error fetching LEI for Fund Company {fund_company}: {e}")


# Append data row to the current batch's data_rows list
data_rows.append({
'ISIN': isin,
'RIC': ric[:max_rics_per_isin],
'FundLegalStructure': fund_legal_structure,
'FundType': fund_type,
'FundCompany': fund_company,
'Legal Entity Identifier': str(lei) # Add LEI to the data
})


api#contentfundscompany-research
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.

@francesco.fabris01

Please share the rics_list that can be used to replicate this issue. Therefore, we can test it.

0 ['LP65103239', 'A2PJ9SX.DX', 'E4G9fr.FP^K10']

1 ['LP68058107', 'A1C027X.DX', 'KEN5fr.FP^K10']

2 ['LP68032732', '10210797.S', 'A1CXHBX.DX']

3 ['LP68163147', 'LU0823434401.LUF', 'A1T80KX.DX']

4 ['LP68319008^L22']

5 ['LP68280028', 'A12EB5X.DX']


This is part of the pd.series called 'RIC' and every list in the rows is rics_list. Thanks

Upvotes
Accepted
1.4k 5 3 6

Hi @francesco.fabris01

I do recommend to use rd library that has search capability. If you start from the Fund Company Name you can try then:

# your sample fund:
fund_company = rd.get_data( 'LP65103239','TR.FundCompany')

#get the PermID from name:
perm_id = rd.discovery.search(
        view = rd.discovery.Views.SEARCH_ALL,
         filter = f"CommonName eq '{fund_company['Fund Company'][0]}'",
        select = "PI"
    )

#get the LEI code from PermID:
rd.get_data(perm_id['PI'][0],['TR.LegalEntityIdentifier','TR.CommonName'])
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.

It works but there are a lot of companies for which I am not able to retrieve the LEI from this code despite on DIB there is the actual LEI code. How is this possible? can you implement the code?

Hi @francesco.fabris01 can you share an example? Thx

fund_company = 'AXA Investment Managers Paris SA'
# get the PermID from name:
perm_id = rd.discovery.search(
view=rd.discovery.Views.SEARCH_ALL,
filter=f"CommonName eq '{fund_company}'",
select="PI"
)
# get the LEI code from PermID:
print(rd.get_data(perm_id['PI'][0], ['TR.LegalEntityIdentifier', 'TR.CommonName']))


creates this error:

Traceback (most recent call last):

File "/Users/francescofabirs/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3802, in get_loc

return self._engine.get_loc(casted_key)

File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item

File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'PI'



Also, if you input AXA Investment Managers Paris SA DIB manually into Workspace, you can find LEI code.

Upvotes
1.4k 5 3 6

hi @francesco.fabris01

It looks that the name cannot be recognized. You can try with "AXA Investment Managers Paris"

Instead of the dealin with names it would be better to deal with IDs. In this case you can get OrgId insted of the fund name. Depending on the fund it gives you one or more OrgIds which you can then parse and send it similarily as the name.

org_id = rd.discovery.search(
view=rd.discovery.Views.FUND_QUOTES,
filter = "RIC eq 'LP65103239'",
select="IssuerAdministratorOrgId"
)

perm_id = rd.discovery.search(
view=rd.discovery.Views.SEARCH_ALL,
filter=f"Orgid eq '111245'",
select="PI"
)
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.