Historical Ownership Data with setlabel and fetch_refinitiv_data
Client was able to get that Ownership Summary data from the following code.
# LOCATION
import refinitiv.data as rd
import pandas as pd
b = ['SetLabel(TR.InstrStatLocationId,location),SetLabel(TR.InstrStatLocation,locationName)',
'SetLabel(TR.CategoryInvestorCount,investorCount),SetLabel(TR.CategoryOwnershipPct,os)',
'SetLabel(TR.InstrStatCatSharesHeld,position)','SetLabel(TR.InstrStatCatShrsHldVal,heldValue)','StatType=3','Curn=USD']
b_ = fetch_refinitv_data('GE',b)
region = ['North America', 'Europe', 'Asia / Pacific', 'Africa', 'Middle East', 'Latin America']
b_[b_['LOCATIONNAME'].isin(region)]
Now he wants to get data for last month/quarter/year (historically) data. When I tried copy and pasting this code in Codebook - I am getting error "
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/tmp/ipykernel_76/2082299371.py in <module>
11 'SetLabel(TR.InstrStatCatSharesHeld,position)','SetLabel(TR.InstrStatCatShrsHldVal,heldValue)','StatType=3','Curn=USD']
12
---> 13 b_ = fetch_refinitv_data('GE',b)
14
15 region = ['North America', 'Europe', 'Asia / Pacific', 'Africa', 'Middle East', 'Latin America']
NameError: name 'fetch_refinitv_data' is not defined"
Best Answer
-
Hi @mae.diaz
If this is your first time working with the APIs, I would suggest you review the learning material within our Developer Portal. There are a number of resources for you to help understand basic examples. I'm assuming you are using Refinitiv Workspace - You can use CodeBook as a built-in development Jupyter environment - it will have plenty of examples within there.
Have you tried the above example within Jupyter? It doesn't have to be defined within a function - I would personally start off really basic like you did above - don't make things fancy - simply do the minimum to get data then work from there.
0
Answers
-
Hi @mae.diaz
When you run code within a Jupyter Notebook, you have the freedom to place code within cells. In your case, it appears you are executing a cell that contains the code: fetch_refiniti_data() but have not executed the cell where this function is defined.
0 -
Hi @nick.zincone how can I do it and may I ask for an example?
Also, I have manually created code;
import refinitiv.data as rd
rd.open_session()
df = rd.get_data(
universe = ['GE'],
fields = [
'TR.InstrStatLocationId',
'TR.InstrStatLocation',
'TR.CategoryInvestorCount',
'TR.CategoryOwnershipPct',
'TR.InstrStatCatSharesHeld',
'TR.InstrStatCatShrsHldVal',
'TR.InvestorRegion'
],
parameters = {
'SDate': '0CY',
'CH': 'date'
}
)
display(df)
Can the above code be the same function as what client had given earlier? Appreciate your help, thank you.
0 -
@nick.zincone, I have tried the first code above in Codebook which gave me the error message that I mention and check how you reference the b_ = fetch_refinitv_data('GE',b)
region = ['North America', 'Europe', 'Asia / Pacific', 'Africa', 'Middle East', 'Latin America']
b_[b_['LOCATIONNAME'].isin(region)].
Instead, I manually created a code in CodeBK app - I'm using both Eikon and Workspace to get the data for "GE" and fields with "As of" parameter. All is set on my end, thanks again for checking my question.
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 中文论坛