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
3 1 2 4

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?

refinitiv-dataplatform-eikondatapython api
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.

1 Answer

· Write an Answer
Upvote
Accepted
80.1k 257 52 75

@CharlesYan

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.df

The 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"])
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.

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.

@CharlesYan

Please try with "TR.CompanyMarketCap" field.

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.

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,"",""]
  
converted
Hi, Bunkowski. Thx for the assistance in detail. I will have a try right now.
BTW, can I confirm with you that using rd does not require to set app key first, does it?

@CharlesYan

It still requires app key but you can set it in the configuration.

1699960129515.png

Then, set the sessions.default to "desktop.workspace".


1699960129515.png (7.2 KiB)
Does it mean before I run my code, I need to run a file with this configuration?

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.