How to use get_data with RIC, date combinations?

Hi all,
I imported a dataframe with RICs and dates. Now I would like to use get_data to retrieve market capitalization for all RICs at the specific dates. Is that possible with python eikon api?
Dataframe looks like this:
I tried the following :
idfy = pd.read_csv(\distcompfy.csv', encoding='utf-8')
mc, err =ek.get_data(list(idfy['RIC']), fields = ['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value' ] , parameters={'Scale': 6, 'Curn': 'USD', 'SDate': list(idfy['date'])})
But Python returns: "Error code 400 | Backend error. 400 Bad Request"
Is there a way to retrieve the data?
Best
Simon
Best Answer
-
Hi @sile
The problem is on the list of date in parameters.
You cannot make a request with SDate as a list.
If you want a range of date, you can follow this request.
But if you want a specific date not in range, you have to separate your request.
0
Answers
-
To add to the answer by @chavalit-jintamalit, to specify the frequency of the series you can add Frq parameter to the request. E.g. to retrieve annual series of market cap values you can use
ek.get_data('000002.SZ',
['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value'],
{'Scale': 6, 'Curn': 'USD',
'SDate': '20160101', 'EDate': '20190101', 'Frq':'FY'})0 -
Thank you both. That's helpful. I already implemented my code as in @Alex Putkov.1 response. However, the problem here is that Fiscal Year Ends depend on the company. The FY of some companies' ends e.g., in March.
My dataframe includes all RICs with the correspondinf FY end over the period from 1999-2017.
Now I use the following loop, however it takes really long:
Do you have a recommendation how to speed it up, or an alternative way to cope with the FY end problem?
rics = list(idfy.RIC.values)
dates = list(idfy.date.values)
mc = {}
for x in range(0,10000,1):
mc[x], err =ek.get_data(rics[x], fields = ['TR.CompanyMarketCap.date', 'TR.CompanyMarketCap.value' ] , parameters={'Scale': 6, 'Curn': 'USD', 'SDate': dates[x]})0 -
You could maybe group your stocks by fiscal year end date and retrieve market cap for multiple stocks that have the same fiscal year end date in a single request. This is the only optimization I can think of.
0 -
I did it as you suggested and it works fine. Many thanks.
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 33 Data Model Discovery
- 682 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.8K Refinitiv Data Platform
- 622 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 84 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛