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 3

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()
eikoneikon-data-apipythonworkspacerefinitiv-dataplatform-eikonworkspace-data-apihistoricalcodebook
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
Upvotes
Accepted
39.4k 77 11 27

@rafal.janicki1

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.

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.

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'

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.