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
1 3 3 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-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apitime-series
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.

@paul67

Thank you for your participation in the forum. Are any of the replies below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply that best answers your question. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvotes
Accepted
39.4k 77 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 512.0 KiB each and 1.0 MiB total.

Upvotes
25.3k 87 12 25

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

hi @paul67

Please see changes to the answer explaining tuple return value.

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.