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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 0

Get data with a variety of start and end dates

I'm trying to download post-earnings return data for a list of stocks.

For example, let's say AAPL, BA, C report on 1/1, 2/1, and 3/1 and I want returns over the 7 days after they report. How should I get the lists of start and end dates into this code?

returns = ek.get_data(instruments = ['AAPL.O', 'BA.N', 'C.N'], fields = ['TR.TotalReturn'], parameters= {'Sdate': ???, 'EDate': ???})

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.

Upvotes
Accepted
18k 21 12 20

Hi @jsinegal

You can have parameter in field level (applies to all RIC):


Or you can have parameter in request level (applies to all fields and all RIC)

Note that you can only have 1 set of start/end date:


ahs1.png (46.9 KiB)
ahs2.png (64.4 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.

Upvotes
18k 21 12 20

Hi @jsinegal

Here is an example:

df,e = ek.get_data(['AAPL.O', 'BA.N', 'C.N'],
                   ['TR.TotalReturn(SDate=2020-02-03,EDate=2020-02-07,Frq=D).Date',
                   'TR.TotalReturn(SDate=2020-02-03,EDate=2020-02-07,Frq=D)',
                   'TR.TotalReturn(SDate=2020-01-01,EDate=2020-01-07,Frq=D).Date',
                   'TR.TotalReturn(SDate=2020-01-01,EDate=2020-01-07,Frq=D)'])
df


Alternatively, you can seperate them into multiple API calls


ahs.png (43.1 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.

Upvotes
3 0 0 0

@chavalit.jintamalit for a larger amount of data (let's say all the stocks in the S&P 500), is there a way to pass in a list of associated dates? I can get it to accept instruments = list_of_stocks, but not 'Sdate': list_of_dates




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.

Upvotes
18k 21 12 20

Hi @jsinegal

Is this what you are looking for?


ahs.png (30.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.

Upvotes
3 0 0 0

@chavalit-jintamalit in that case, every stock in SPX is going to have a different earnings date. I have for instance: stocks = [AAPL, BA, C...] sdates = [2/1/2016, 2/17/2016, 2/21/2016...] edates = [2/8/2016, 2/24/2016, 2/28/2016...] and would like to get a list of returns as output without inputting each set of dates individually.

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.

Upvotes
3 0 0 0

Thank you. It seems there is unfortunately not a good way to call for one date per company. I appreciate the help!

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