I am trying to pull data from Refinitiv using Python via an API key. Normally, I use an Excel add-on, but this time, the data I need requires a lot of iterations, so I had to revert to Python with the help of Chatgpt, although I am not confident using it. As expected, the code generated by Chatgpt doesn't work, and I cannot troubleshoot, even after asking colleagues with an expert knowledge level of Python, because of Refinitiv’s specific concepts.
Let me explain what information I need, and maybe you can point me in the right direction or offer a solution to getting the data. I want to call all the active companies in the public and private universe in Refinitiv. Then, retrieve their ticker (instrument) code, company name, industry, and country(headquarters). Then, in the next columns, I need information on revenue, profitability, and number of employees for now (I will need to add some other variables at later stages) (all historical-time series).
I could successfully write a simple code, see below, and pull data. However, I have a rather ridiculous filter here, I am only calling companies with more than 2mn employees. So, the code worked. But when I tried for all companies, it didn't due to time-out or 7500 identifier limit on Refinitiv side, most probably.
Can I ask how can I change the code below to pull data for all companies in public private universe: "
import os
os.environ["LD_LIB_CONFIG_PATH"] = "Configuration"
import lseg.data as ld
from lseg.data.discovery import Screener
import datetime
from IPython.display import display, clear_output
ld.open_session()
mklist = Screener('U(IN(Equity(active,public,private,primary))/*UNV:PublicPrivate*/), TR.Employees(Period=FY0)>=0,CURN=USD')
print(list(thelist))
mkframe = ld.get_data(thelist,
fields=['TR.Revenue.date','TR.ISINCode','TR.CommonName','TR.HQCountryCode','TR.NAICSSector', 'TR.Revenue', 'TR.TotalAssets', 'TR.Employees', 'TR.OperatingProfit'],
parameters={'SDate':0, 'EDate':-10, 'curn':'usd'})
mkframe.to_csv('todaysdate.csv', index=False)
"
The resulting list is just Walmart Inc, China, People's Republic of (Government), All China Federation of Supply and Marketing Cooperatives, and Gobierno Federal De Los Estados Unidos Mexicanos. I want this same table but for +16000 companies in the Refinitiv universe. However, I am limited by the number of "identifiers"(number of companies in one query)from Refinitiv side. Therefore I need to do this in bathces. The filtering criteria "TR.Employees(Period=FY0)>=2000000" does not serve any function other than limiting the firms pulled in one go, so any other smarter. option would be preferred. Could you help me in accessing this data for my research please?
Thank you,
Melik