Is this query optimal?

I was referred here to customer support.

This requests hangs, sometimes works, and unexplicable throws "backend error. 400 Bad Request" unreproducible errors. Is there something sub-optimal about my request, or another way of doing this that plays nicer with the API?

 data_holding, err = ek.get_data( 
'US4781601046'
,
fields=["TR.InvestorFullName",
"TR.InvParentType",
"TR.InvestorRegion",
"TR.InvestorType",
"TR.SharesHeld.Date",
"TR.SharesHeld",
"TR.SharesHeldValue",
"TR.SharesHeldValChg"
],
parameters={'SDate': '1980-01-01'.format(start_date),
'EDate': '2020-12-31'.format(end_date),
'Frq': 'D'})

Best Answer

  • @thok

    I suggest you use CodeCreator app to help you construct data retrieval calls. Using CodeCreator app you can explore the metadata including field names for data items you're interested in and parameters applicable to these fields. The fields you retrieve are not provided as daily timeseries. According to the metadata, these fields can only be retrieved "as of" a specific date. In other words only the SDate parameter for these fields is valid. The Frq parameter in your request is ignored, whereas what you get when you include both SDate and EDate is anybody's guess. It's not documented. What is clear however is that the request you're submitting is for a large amount of data, which is very taxing on the backend. I'm not at all surprised that it takes a long time to get a response or that you receive "Backend error. 400 Bad Request" as a response, which indicates a timeout from the backend. If anything, I'm surprised to hear this request sometimes works for you.