Fetching a company’s TRBC codes¶
Show code cell content
import refinitiv.data as rd
rd.open_session()
/home/runner/.local/share/virtualenvs/refinitiv-data-python-cookbook-I-HIyNf4/lib/python3.10/site-packages/refinitiv/data/_access_layer/session.py:71:FutureWarning:
You open a platform session using the default value of the signon_control parameter (signon_control=True).
In future library version v2.0, this default will be changed to False.
If you want to keep the same behavior as today, you will need to set the signon_control parameter to True either in the library configuration file
({'sessions':{'platform':{'your_session_name':{'signon_control':true}}}}) or in your code where you create the Platform Session.
These alternative options are already supported in the current version of the library.
[Error 400] - {'error': 'access_denied', 'error_description': 'Account locked out due to provide incorrect password.'}
<refinitiv.data.session.Definition object at 0x7eff182a1510 {name='rdp'}>
You can use the Refinitiv Data Library for Python to retrieve the The Refinitiv Business Classification (TRBC) codes associated with a company. The standard is used by Refinitiv to classify business establishments for economic analysis.
To do acquire the data, pass a company’s Refinitiv Instrument Code to the get_data
method with a request for TRBC related fields.
Here’s a query for Thomson Reuters:
rd.get_data(
'TRI.N',
fields=[
# Basic stuff
"TR.CommonName",
"TR.TickerSymbol",
# TRBC codes
"TR.TRBCEconSectorCode",
"TR.TRBCEconomicSector",
"TR.TRBCBusinessSectorCode",
"TR.TRBCBusinessSector",
"TR.TRBCIndustryGroupCode",
"TR.TRBCIndustryCode",
"TR.TRBCIndustry",
"TR.TRBCActivityCode",
"TR.TRBCActivity",
]
)
Session is not opened. Can't send any request
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 rd.get_data(
2 'TRI.N',
3 fields=[
4 # Basic stuff
5 "TR.CommonName",
6 "TR.TickerSymbol",
7 # TRBC codes
8 "TR.TRBCEconSectorCode",
9 "TR.TRBCEconomicSector",
10 "TR.TRBCBusinessSectorCode",
11 "TR.TRBCBusinessSector",
12 "TR.TRBCIndustryGroupCode",
13 "TR.TRBCIndustryCode",
14 "TR.TRBCIndustry",
15 "TR.TRBCActivityCode",
16 "TR.TRBCActivity",
17 ]
18 )
File ~/.local/share/virtualenvs/refinitiv-data-python-cookbook-I-HIyNf4/lib/python3.10/site-packages/refinitiv/data/_access_layer/get_data_func.py:63, in get_data(universe, fields, parameters, use_field_names_in_headers)
57 warnings.warn(
58 "Parameter 'use_field_names_in_headers' is deprecated and will be removed in future library version v2.0.",
59 FutureWarning,
60 )
62 session = get_default()
---> 63 raise_if_closed(session)
65 logger = session.logger()
67 # Library usage logging
File ~/.local/share/virtualenvs/refinitiv-data-python-cookbook-I-HIyNf4/lib/python3.10/site-packages/refinitiv/data/_core/session/tools.py:37, in raise_if_closed(session)
35 error_message = "Session is not opened. Can't send any request"
36 session.error(error_message)
---> 37 raise ValueError(error_message)
ValueError: Session is not opened. Can't send any request
Show code cell content
rd.close_session()