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?



Best Answer

Answers

  • 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?