How to retrieve monthly institutional shareholding data for over 200 firms from 2003 to 2023 using E
Hi everyone,
I am relatively new using Eikon API and I am also relatively unfamiliar with the code. I want to retrieve the monthly institutional shareholding data for about 200 firms from 2003 to 2023 without having to download the shareholder report for every company one by one. Specifically, taking one company's shareholder report as an example, it contains information of every investor's name, the % Outstanding, position ($M), position change (etc). However, for each of my 200 firms, I want to retrive every investor's name, the percentage of shares held by each investor (TR.PctOfSharesOutHeld), the Investor Type ( 'TR.InvParentType') of each investor, the Investor Sub-type ('TR.InvestorType' of each investor, the investment stype ('TR.InvInvestmentStyleCode') of each investor, the country/region ('TR.InvAddrCountry') in which the investor locates every month from 2003 to 2023. I know there is monthly data available through checking one specific company's shareholder report in Refinitiv Workspace. I want the final dataframe to be in the following format (I just choose two companies as an example. I want my dataframe to include all 200 firms, the Date column to include all month from 2003/1/31 to 2023/12/31 for every firm, the Investor Name and the following columns to include all investors for the specific company). Is there any code that will enable me to do this?
In addition, I have already tried the following code myself. But it fails to return me the dataframe. Can anyone help me with this? Thank you very much!
ek.set_timeout(200)
instruments = ['AAL.L' 'ABDN.L' 'ABF.L' 'ADML.L' 'AHT.L' 'ANTO.L' 'ATST.L' 'AZN.L'
'BAB.L' 'BAES.L' 'BALF.L' 'BARC.L' 'BATS.L' 'BDEV.L' 'BEZG.L' 'BKGH.L'
'BLND.L' 'BOY.L' 'BP.L' 'BWNG.L' 'BWY.L' 'BYG.L' 'CAL.L' 'CBRO.L' 'CCL.L'
'CHG.L' 'CLDN.L' 'CLLN.L' 'CLSH.L' 'CNA.L' 'CNE.L' 'CPG.L' 'CPI.L'
'CRDA.L' 'CURY.L' 'DLAR.L' 'DLN.L' 'EMG.L' 'EZJ.L' 'GFRD.L' 'GFTU_u.L'
'GNC.L' 'GPEG.L' 'GRI.L' 'GSK.L' 'HBR.L' 'HEAD.L' 'HFD.L' 'HLCL.L'
'HLMA.L' 'HMSO.L' 'HSBA.L' 'HSX.L' 'HTG.L' 'HWG.L' 'ICGIN.L' 'IHG.L'
'III.L' 'INF.L' 'INVP.L' 'ITRK.L' 'ITV.L' 'IWG.L' 'JDW.L' 'JMAT.L'
'KGF.L' 'KIE.L' 'KLR.L' 'LLOY.L' 'LSEG.L' 'MARS.L' 'MCG.L' 'MGNS.L'
'MKS.L' 'MSLH.L' 'MTO.L' 'NG.L' 'NWG.L' 'NXT.L' 'PAGE.L' 'PAGPA.L'
'PFC.L' 'PFD.L' 'PHARP.L' 'PINE.L' 'PNN.L' 'PSN.L' 'PSON.L' 'PZC.L'
'RAT.L' 'RIO.L' 'RNK.L' 'ROR.L' 'RR.L' 'RSW.L' 'RTO.L' 'RWI.L' 'SBRY.L'
'SDR.L' 'SDY.L' 'SFR.L' 'SGE.L' 'SGRO.L' 'SHEL.L' 'SHI.L' 'SJP.L'
'SMDS.L' 'SMIN.L' 'SMWH.L' 'SN.L' 'SPT.L' 'SPX.L' 'SRP.L' 'SSE.L'
'STAN.L' 'SVS.L' 'SVT.L' 'SXS.L' 'TATE.L' 'TPK.L' 'TPT.L' 'TSCO.L' 'TW.L'
'ULVR.L' 'UTG.L' 'UU.L' 'VANQ.L' 'VCTX.L' 'VOD.L' 'VSVS.L' 'VTYV.L'
'WEIR.L' 'WG.L' 'WKP.L' 'WTB.L' 'ZIG.L']
dataframes = {}
# Loop through each instrument and fetch data
for instrument in instruments:
success = False
retries = 100
for attempt in range(retries):
try:
df, err = ek.get_data(
[instrument],
['TR.CompanyName','TR.PctOfSharesOutHeld.date', 'TR.PctOfSharesOutHeld', 'TR.InvestorFullName', 'TR.InvParentType', 'TR.InvestorType', 'TR.InvInvestmentStyleCode', 'TR.InvestorAddrCity', 'TR.InvAddrCountry'],
parameters={'SDate': '2003-01-01', 'EDate': '2024-01-02', 'Frq': 'M'}
)
if err is None:
dataframes[instrument] = df
success = True
print(f"Data successfully retrieved for {instrument}")
break # Exit the retry loop on success
except ek.EikonError as e:
print(f"Attempt {attempt + 1} failed for {instrument}: {e}")
time.sleep(5) # Wait 5 seconds before retrying
if not success and attempt == retries - 1:
print(f"Failed to retrieve data for {instrument} after {retries} attempts.")
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 中文论坛