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 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-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
9.7k 49 38 60

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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea