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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 2 1

Time series using ek.get_data

I am trying to retrieve mid price for the following ticker using the below

df = ek.get_data('EURCBS3M=ICAP', ['TR.ASKPRICE.Date', 'TR.ASKPRICE','TR.BIDPRICE'], parameters={'SDate':'2017-08-01', 'EDate':'2020-09-14'})

I do not believe Mid is available so i retreive Bid and Ask

So i am first ading new column for Mid

df['Mid'] = df['TR.ASKPRICE'] + df['TR.BIDPRICE']

but coming back with error :

df['Mid'] = df['TR.ASKPRICE'] + df['TR.BIDPRICE']

TypeError: tuple indices must be integers or slices, not str


Can someone explain what is going wrong here - whey it does not recognise above as dataframe?

Also by retrieving in this manner is the Date column recognised as an actual date?



eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythontime-series
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
39.2k 75 11 27

@paul67

To answer your question about the Date column, get_data method returns date and time stamps as ISO 8601 strings. To convert these strings to datetime type use pandas.to_datetime method.

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
20.3k 73 10 20

Hi @paul67

The return value from the get_data is a tuple rather than a dataframe as it returns the dataframe and any errors

So, the following works for me

df,err = ek.get_data('EURCBS3M=ICAP', ['TR.ASKPRICE.Date', 'TR.ASKPRICE','TR.BIDPRICE'], parameters={'SDate':'2017-08-01', 'EDate':'2020-09-14'})

df['Mid'] = (df['Ask Price'] + df['Bid Price'])/2


Can you also expand on your question about the date Column - I don't fully understand the question?

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