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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

get_timeseries() custom function error

Hello,

I'm trying to create my own function with an Eikon request. The aim of the funciton is to return a dictionnary of DataFrame with tick data. At first the function worked, but suddenly an error strated to appear: " TypeError: get_timeseries() got multiple values for argument 'fields' ". I tried to rebuild it step by step, and it appears that when I use start and en date as function params it starts to bug, here is to code:

def df_request(ric_list, start_date, end_date):
# Datetime format
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
# Dict
df_request = {}
# Eikon raw request
raw_request = ek.get_timeseries(
ric_list,
start_date,
end_date,
fields = ['BID','ASK','BIDSIZE','ASKSIZE'],
calendar = 'tradingdays',
interval = 'tas',
raw_output = 'true'
)
# Header
list_fields = []
# Loop to crate the header
for fld in raw_request['timeseriesData'][0]['fields']:
list_fields.append(fld['name'])
# Add key/value pairs
for i in range(len(raw_request['timeseriesData'])):
df_request.update({raw_request['timeseriesData'][i]['ric']:pd.DataFrame(raw_request['timeseriesData'][i]['dataPoints'], columns = list_fields)})

return df_request;

With the test here: data = df_request(['BNPP.PA','MSFT.O'],'2019-11-25','2019-11-28')

I repeat myself but this code used to work 2 days ago...

Thank you in advance for your help

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapi
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
18k 21 12 20

Hi @kenan.jouglet

I made 2 sample df_request1 and df_request2

Hope this help !.


df_request1 same with your code:


df_request2, just fixed the API a little.


ahs1.png (71.2 KiB)
ahs2.png (77.2 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