HTTP Error: Backend error. 400 Bad Request

Hi, I'm trying to pull some data with the following:

screener_tsvx = "SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeMarketIdCode,""TSXV"",""XTNX"",""XTSE"",""XTSX""), TR.AvgDailyValTraded20D>=GMEDIAN(ZAV(TR.AvgDailyValTraded20D),universe=""univ""), CURN=CAD)" 
ek.get_data([screener_tsvx],["TR.CommonName"])
# ek.get_data([screener_tsx],["TR.CommonName;TR.InstrumentType;TR.CompanyMarketCap"])

It works in excel, but in my jupyter notebook I get the following HTTPError:

---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-100-fa4ae8947122> in <module>()
1 screener_tsvx = "SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeMarketIdCode,""TSXV"",""XTNX"",""XTSE"",""XTSX""), TR.AvgDailyValTraded20D>=GMEDIAN(ZAV(TR.AvgDailyValTraded20D),universe=""univ""), CURN=CAD)"
----> 2 ek.get_data([screener_tsvx],["TR.CommonName"])
3 # ek.get_data([screener_tsx],["TR.CommonName;TR.InstrumentType;TR.CompanyMarketCap"])

~\Anaconda3\lib\site-packages\eikon\data_grid.py in get_data(instruments, fields, parameters, field_name, raw_output, debug)
149 payload = {'instruments': instruments,'fields': fields_for_request}
150 if parameters: payload.update({'parameters': parameters})
--> 151 result = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug)
152
153 if raw_output:

~\Anaconda3\lib\site-packages\eikon\json_requests.py in send_json_request(entity, payload, ID, debug)
85 if response.status_code == 200:
86 result = response.json()
---> 87 check_server_error(result)
88 return result
89 if response.status_code == 401:

~\Anaconda3\lib\site-packages\eikon\json_requests.py in check_server_error(server_response)
133 else:
134 status_code = server_response['ErrorCode']
--> 135 raise requests.HTTPError(error_message, response=server_response)
136
137 # check DataGrid error

HTTPError: Backend error. 400 Bad Request

I've seen some suggestions of queries timing out, but I'm not sure if this is the case. I've also been unable to find a detailed documentation on how the `instruments` field for the get_data function can be specified. I've been trying to use the Screener function as a work around, and now I've run into the HTTP Backend error. Not entirely sure what my options are now. Any suggestions, advice would be nice.

Thank you!

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    The use of equity screener through Eikon Data APIs is not supported yet. One reason for this is that currently any get_data request is automatically timed out from the server side if the server cannot return the data requested in 15 seconds. Rendering the data through screener can take much longer than 15 seconds to complete, in which case you get back "HTTPError: Backend error. 400 Bad Request". Work is being done to address this issue. Until this work is complete the screener through Eikon Data APIs can only be used for basic expressions that the server can render in less than 15 seconds.

    Could you elaborate on what you expect from "detailed documentation on how the instruments field for the get_data function can be specified"? It seems you've already checked the "Eikon Data APIs for Python - Reference Guide" available from the Documentation tab on Eikon Data APIs page on this portal, which provides definition of all the methods and their signatures available in Eikon Data APIs for Python. Per this document the "instruments" argument is a string representing an identifier for a single instrument or a list of strings where each string represents an instrument identifier. For instrument identifier you can use a variety of symbol types including RIC, ISIN, CUSIP, SEDOL, Wertpapierkennnummer, PermID etc. If you have a list of instrument identifiers for which you need market or fundamental & reference data, you can use this list directly to retrieve the data using get_data method, e.g.

    ek.get_data(['TRI.N','AAPL.O'],['TR.Revenue'])
    The screener is useful when you need to identify stocks that satisfy your criteria.

Answers