I am currently using the Refinitiv DataPlatform Python library for intraday data analysis. My focus is on equities, and I have successfully implemented a routine to retrieve 1-minute interval data using the following code:
import pandas as pd
import refinitiv.dataplatform as rdp
# Define the datetime range
start_date = '2023-08-18'
end_date = '2023-09-17'
all_data3 = pd.DataFrame()
# Get data
for RIC in rics_list:
response = rdp.HistoricalPricing.get_summaries(
universe=RIC,
interval=rdp.Intervals.ONE_MINUTE,
start=start_date,
end=end_date,
fields=['TRDPRC_1', 'ACVOL_UNS', 'HIGH_1', 'LOW_1', 'BID', 'ASK']
)
if response is not None and response.data.df is not None:
df_bid_ask = response.data.df
df_bid_ask.columns = pd.MultiIndex.from_product([[RIC], df_bid_ask.columns])
df_bid_ask.index = pd.to_datetime(df_bid_ask.index)
# Adjust the time filter for NYSE trading hours
df_bid_ask = df_bid_ask.between_time('14:30', '21:00')
df_bid_ask = df_bid_ask.loc[lambda x: x.index.dayofweek < 5]
if all_data3.empty:
all_data3 = df_bid_ask
else:
all_data3 = pd.concat([all_data3, df_bid_ask], axis=1)
# Display the concatenated data
print(all_data3.tail())
This code has been effective for gathering 1-minute interval data, but I've noticed significant gaps in the data due to the absence of tick data for periods without trades.
To address this, I'm looking to aggregate the data over longer intervals, specifically 20-minute and/or 30-minute periods. However, I am uncertain about the correct interval codes to use for these timeframes in the rdp.HistoricalPricing.get_summaries
function.
Could anyone provide guidance on the appropriate interval codes for 20-minute and 30-minute data retrieval using the Refinitiv DataPlatform Python library? Any additional insights into handling intervals with sparse data would also be greatly appreciated.
Thank you in advance!