RDP Performance - get_historical_price_summaries
Hi,
I have a task to retrieve intraday turnover for S&P500 stocks.
Only possibility which I can see now is to retrieve data and aggregate it via codebook.
Unfortunately I am not able to retrieve data for 500 stocks (price and volume) and aggregate it (after waiting over 30 mins every time, nothing happens).
Can you help in resolving it?
Example code:
import refinitiv.dataplatform as rdp
import datetime
import pandas as pd
rdp.open_desktop_session('DEFAULT_CODE_BOOK_APP_KEY')
sp_chain = rdp.StreamingChain(
session = rdp.get_default_session(),
name = '0#.SPX')
sp_chain.open(with_updates = False)
sp_constituents = sp_chain.get_constituents()
RICs = sp_constituents # the list of RICs
s_date = "2020-12-22 13:00" # start date
e_date = "2020-12-22 21:00" # end date
Field = "ACVOL_UNS" # the field of these RICs
data = pd.DataFrame() # define data is a DataFrame
for aRIC in RICs: # request turnover for each RIC
df = rdp.get_historical_price_summaries(
universe = aRIC,
start = s_date,
end = e_date,
interval = rdp.Intervals.ONE_HOUR, # Supported intervals: ONE_MINUTE, FIVE_MINUTES, TEN_MINUTES, THIRTY_MINUTES, ONE_HOUR
fields=[Field],
sessions = [
rdp.MarketSession.PRE,
rdp.MarketSession.NORMAL,
rdp.MarketSession.POST])
if df is None: # check if there is any error
print("Error for RIC " + aRIC + ":" + str(rdp.get_last_status()['error'])) # print the error
else:
df[Field] = df[Field].astype(float) # convert string type to float
data[aRIC] = df[Field] # create the RIC's last price column
data['S&P'] = data.sum(axis=1)
print(data['S&P'][-1])
data['S&P'].plot()
Best Answer
-
When posting a code sample, make sure to use the code block feature in the post editor: the button with </> icon. Code block helps preserve code formatting, indentation etc. The code you included lost all formatting, which means I have to guess for example where the for loop in the original code ends.
There's a bunch of issues I see here. One is a bug in RDP library, which ignores the value of "interval" kwarg for intraday intervals and always returns timeseries in default one minute summarization. Then there's default time zone, the availability of extended market trades for NYSE vs. NASDAQ stocks. But none of these issues would result in the code not returning, if that is indeed what you experienced. I suggest you include some print statements to help you trace the execution of your code, e.g. include "print(aRIC)" within the for loop to help you follow the progression of the code running through the loop.
0
Answers
-
Thanks, I corrected the post.
I know about interval bug, but this is not a case - I am able to retrieve data only for ~20 stocks, even for short time frame.
I will try to implement some kind of 'check'0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 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
- 370 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛