For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
32 5 4 2

How do I constrain my ek.get_data() request to specific dates under the variable 'TR.RNSAnnouncedDate'?

I use the following code to download a csv of the previous 1 year's data for the instruments in my list and for the fields specified. My understanding is that using this method I am retrieving all of the data (unconstrained by dates) and then modifying that data so that a subset, constrained by 'TR.RNSAnnouncedDate', is downloaded as a csv. Is there a way I can only download the data for the previous year to make the request more efficient? In other words, can I apply a date parameter for 'TR.RNSAnnouncedDate' in my initial retreival?


The code:

#import packages

import eikon as ek # the Eikon Python wrapper package

import pandas as pd

import numpy as np

import datetime

from datetime import timedelta, date, datetime

from pandas.tseries.offsets import BDay


#connects to Bill's Eikon terminal

ek.set_app_key('72d2821f21064a0b8890860db39e375eacd87e24')


#retreive the RICs from Eikon

df_rics,e = ek.get_data("lists('Inv Trust List')","TR.RIC")


#convert that into a list and set as an object

ric_list = df_rics['Instrument'].tolist()


#Slice, loop and concatonate the retreival request - must be done in order to avoid a backend request timeout which

#happens when we use too many RICs. n can be toggled below.

n = 50

df = pd.DataFrame()

for ric_chunk in [ric_list[i:i + n]

for i in range(0, len(ric_list), n)]:

tmp_df, e = ek.get_data(ric_chunk,

['TR.RNSFilerName',

'TR.RNSAnnouncedDate',

'TR.RNSTransactionType',

'TR.RNSARNumShrsTransacted',

'TR.RNSARPctOSTransacted',

'TR.RNSARTransactionPrice',

'TR.RNSARMktValTransaction',

'TR.RNSARTotShrsPostTrans',

'TR.RNSARPctOSPostTrans'])

df = tmp_df.append(df)


#set the dates for the csv file we wish to download

end_date = date.today()

start_date = end_date - timedelta(days=365)

end_date_str = datetime.strftime(end_date, "%Y-%m-%d")

start_date_str = datetime.strftime(start_date, "%Y-%m-%d")

df['RNS Announced Date'] = pd.to_datetime(df['RNS Announced Date'])

mask = (df['RNS Announced Date'] > start_date_str) & (df['RNS Announced Date'] <= end_date_str)

df = df.loc[mask]


df.rename(columns={'RNS AR Price (at Transaction) - £': 'RNS AR Price (at Transaction) GBP',

'RNS AR Market Value of Transaction - £': 'RNS AR Market Value of Transaction - GBP'},

inplace=True)


#create file name and export as CSV

todays_date = date.today()

todays_date_str = datetime.strftime(todays_date, "%Y%m%d")

df.to_csv('Daily API Download_' + todays_date_str + '.csv')


eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythondate
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
18k 21 12 20

Hi @bill39

In the general case, you can use "Data Item Browser" to check field supported parameters.

For example, I am checking TR.TURNOVER field to see any support parameters, or whether it supports timeseries, etc...


From this information, I could retrieve the data in several ways.


However, in this case, the TR.RNSAnnouncedDate does not show up on the "Data Item Browser"

So you have to contact Refinitiv Content Helpdesk (https://my.refinitiv.com/) to clarify what parameters are supported by this field. This is a content question and the moderators on this forum are not content experts.


ahs1.png (70.4 KiB)
7016-ahs.png (82.0 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea