How to convert the ticker to RIC and then retrieve the market cap?
Hi, I encountered a problem as mentioned in the title. Currently, I have two ways:
1. rdp.convert_symbols(), where rdp is refinitiv.dataplatform
2. ek.symbology().
Take ['AAPL' , 'MSFT'] as an example. I found method 1 always requires a login and requires to open a session. Is that possible to avoid this issue. I mean only providing app key, say. Is there any converting function in refinitiv.data package?
If I turn bestmatch to True, the function always returns me an error but if False, it's a list. Should I simply select the first component of the list?
Then, for retrieving market cap, which function can I use to complete it more efficiently? Is that possible to only use eikon built-in functions to implement this?
Best Answer
-
Thank you for reaching out to us.
You can use the Refinitiv Data Library for Python instead. The library can be configured to use the desktop session that retrieves data via Eikon or Refinitiv Workspace by using the application key.
The code to convert tickers to RICs looks like this.
response = symbol_conversion.Definition(
symbols=["AAPL","MSFT"],
from_symbol_type=symbol_conversion.SymbolTypes.TICKER_SYMBOL,
to_symbol_types=[
symbol_conversion.SymbolTypes.RIC
],
).get_data()
response.data.dfThe sample code is on GitHub.
Then you can use the retrived RICs with the get_data method to retrieve the market cap.
rd.get_data(["AAPL.O","MSFT.O"],fields=["TR.F.MktCap"])
1
Answers
-
Hi, Jirapongse. Thx so much for such a quick response. It works to me but I found some problems in retrieving market caps from below RICs:
DIVL.K, CONY.K, ROYA.K, NDIA.K, BRAZ.K, etc. I searched them in eikon but they have valid MCap values.
0 -
There is also another problem. For attempts that failed to retrieve the corresponding RIC. Do you know how I can at least give a NA or something else to label it? I input a list of tickers with length 2000, say, but the code returned a dataframe with 1980 rows. The failed attempts were directly discarded by the code.0
-
BTW, can I confirm with you that using rd does not require to set app key first, does it?0
-
Hi @CharlesYan
You can try and merge the results yourself to a dataframe by iterating over a raw response
import pandas as pd
#create an empty dataframe where you will concatenate the results
converted = pd.DataFrame(columns=["Ticker","DocumentTitle","RIC"])
tickers = ["AAPL","UNKNOWN","MSFT"]
response = symbol_conversion.Definition(
symbols= tickers,
from_symbol_type=symbol_conversion.SymbolTypes.TICKER_SYMBOL,
to_symbol_types=[
symbol_conversion.SymbolTypes.RIC,
]
).get_data()
#loop throught he list of results and check if the converted symbol was found
for t in tickers:
try:
converted.loc[len(converted)] = [t,response.data.raw['Matches'][t]['DocumentTitle'],response.data.raw['Matches'][t]['RIC']]
except KeyError:
converted.loc[len(converted)] = [t,"",""]
converted0 -
Please try with "TR.CompanyMarketCap" field.
0 -
It still requires app key but you can set it in the configuration.
Then, set the sessions.default to "desktop.workspace".
0 -
Does it mean before I run my code, I need to run a file with this configuration?0
-
Hi, Bunkowski. Thx for the assistance in detail. I will have a try right now.0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛