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
32 8 6 7

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-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
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. 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()

Hello @bill39,

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

1 Answer

· Write an Answer
Upvotes
Accepted
18.2k 21 13 21

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 512.0 KiB each and 1.0 MiB total.

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.