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 5

How do I generate the data on each day instead of the date of last change?

The code below generates the number of each type of analyst recommendation for TSLA.O. e.g. Number of Strong Buys, Number of Buys, etc.

My data frame has identical rows e.g. multiple lines with date: 2020-06-12 until to 2020-06-29 when there was an update in the data.

How can I amend the request so that I can an output for each day? E.g. the index of my data frame will be:

2020-06-12

2020-06-13

2020-06-14

2020-06-15

2020-06-16

etc.

instead of:

2020-06-12

2020-06-12

...

2020-06-12

2020-06-29


#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 dateutil.relativedelta import relativedelta

#connects to Bill's Eikon terminal
ek.set_app_key('XXXX')

end_date = datetime.now()
start_date = end_date - relativedelta(months=1)
end_date_str = datetime.strftime(end_date, "%Y-%m-%d")
start_date_str = datetime.strftime(start_date, "%Y-%m-%d")
print("start="+start_date_str + " ,end="+end_date_str)

#return dataframe and errors
df,err= ek.get_data('TSLA.O', 
        ['TR.NumOfStrongBuy.date', #show date
         'TR.NumOfStrongBuy',
         'TR.NumOfBuy',
         'TR.NumOfHold',
         'TR.NumOfSell',
         'TR.NumOfStrongSell'],
        {'SDate':start_date_str, 'EDate':end_date_str}) #set start and end date

#show data
df

Thanks

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apidate
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 Answer

· Write an Answer
Upvotes
Accepted
17k 80 39 63

Hi @bill39,

Try using 'TR.NumOfStrongBuy.calcdate' instead:


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