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 time restrict a get_data request and execute it for multiple stocks?

For the following code, what changes do I need to make so that: a) the request is for a list of c.400 stocks that I have created in Eikon b) the request pulls data for the time period today to 1 year previous on a trailing basis (i.e. if I repeat the request in one week the period will have shifted one week forward) Thanks df, e = ek.get_data(['AEFS.L'], [ 'TR.RNSFilerName', 'TR.RNSAnnouncedDate', 'TR.RNSTransactionType', 'TR.RNSARNumShrsTransacted', 'TR.RNSARPctOSTransacted', 'TR.RNSARTransactionPrice', 'TR.RNSARMktValTransaction', 'TR.RNSARTotShrsPostTrans', 'TR.RNSARPctOSPostTrans' ]) df.head()

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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. df, e = ek.get_data(['AEFS.L'],
  2. [
  3. 'TR.RNSFilerName',
  4. 'TR.RNSAnnouncedDate',
  5. 'TR.RNSTransactionType',
  6. 'TR.RNSARNumShrsTransacted',
  7. 'TR.RNSARPctOSTransacted',
  8. 'TR.RNSARTransactionPrice',
  9. 'TR.RNSARMktValTransaction',
  10. 'TR.RNSARTotShrsPostTrans',
  11. 'TR.RNSARPctOSPostTrans'
  12. ])
  13. df.head()

1 Answer

Upvotes
Accepted
18k 21 12 20

a) the request is for a list of c.400 stocks that I have created in Eikon

You can use lists() in get_data

1. Open Screener app

2. Click Edit on List

3. Click "Launch Data Item Library" icon

4. Look at your List/Portfolio code field

I will use "test-port" for my example.

df,e = ek.get_data("lists('test-port')","TR.RIC")
ric_list = df['Instrument'].tolist()
ric_list  #print out list to see what are inside this list.
#ek.get_data(['AEFS.L'],   <<<<<
#ek.get_data(ric_list,     <<<<< replace RIC List


b) the request pulls data for the time period today to 1 year

Refer to sample on https://stackoverflow.com/questions/29370057/select-dataframe-rows-between-two-dates

Here is the sample code:

df, e = ek.get_data(['AEFS.L'],
                    ['TR.RNSFilerName',
                     'TR.RNSAnnouncedDate',
                     'TR.RNSTransactionType',
                     'TR.RNSARNumShrsTransacted',
                     'TR.RNSARPctOSTransacted',
                     'TR.RNSARTransactionPrice',
                     'TR.RNSARMktValTransaction',
                     'TR.RNSARTotShrsPostTrans',
                     'TR.RNSARPctOSPostTrans'])
start_date = '2019-01-31'
end_date = '2020-01-31'
df['RNS Announced Date'] = pd.to_datetime(df['RNS Announced Date'])
mask = (df['RNS Announced Date'] > start_date) & (df['RNS Announced Date'] <= end_date)
df = df.loc[mask]
df

Here is sample output:


ahs1.png (477.7 KiB)
ahs2.png (68.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