famous Backend error. 400 Bad Request starting from yesterday

The api works fine until yesterday. Starting from yesterday, i keep getting the 404 bad request. I simply just wrote a try catch loop for 3 times and it worked through.

However, starting from this morning, my try catch loop could not give me any result. I increased the repeat time to 20 times, and it didn't succeeded once.

To replicate:

python 3.6
import eikon as ek
ek.set_app_id(app_id)
ek.set_timeout(120)
date = '2018-03-28'
symbol_ric = ['AUDCAD=', 'AUDCHF=', 'AUDJPY=', 'AUDNZD=', 'AUD=', 'CADCHF=', 'CADJPY=', 'CHFJPY=', 'EURAUD=',
'EURCAD=', 'EURCHF=', 'EURGBP=', 'EURJPY=', 'EURNZD=', 'EUR=', 'GBPAUD=', 'GBPCAD=', 'GBPCHF=',
'GBPJPY=', 'GBPNZD=', 'GBP=', 'NZDCAD=R', 'NZDCHF=R', 'NZDJPY=', 'NZD=', 'CAD=', 'CHF=', 'JPY=']
req, error = ek.get_data(symbol_ric, parameters={'SDate':f'{date}', 'EDate':f'{date}'}, fields=['TR.ASKPRICE','TR.BIDPRICE'], debug=True)

some times the result is timeout, sometimes it is returns a dataframe with some ric missing

image

full log on one trial with debug=True on is attached.trdebug-log.txt

I tried to get the rate one by one, and it always stuck on AUDCHF=

please advise how to fix this!

Best Answer

  • yikang
    Answer ✓

    i also tried to pack the symbol ric inside a list as following:

    req, error = ek.get_data(symbol_ric, parameters={'SDate':f'{date}', 'EDate':f'{date}'}, fields=['TR.ASKPRICE','TR.BIDPRICE'], debug=True)

    however, the result would be either time out or some symbol prices were missing.

    image

    full log on one trial with debug=True on:

    2018-03-29 11:42:42,448 - DEBUG - http://localhost:9000 "GET /api/v1/data HTTP/1.1" 500 148
    2018-03-29 11:42:42,448 - INFO - Response : 500 - <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Error</title>
    </head>
    <body>
    <pre>Internal Server Error</pre>
    </body>
    </html>

    2018-03-29 11:42:42,448 - INFO - Port 9000 is detected 2018-03-29 11:42:42,448 - INFO - Port 9000 was retrieved from .portInUse file 2018-03-29 11:42:42,448 - INFO - Set Proxy port number to 9000 2018-03-29 11:42:42,448 - INFO - Application ID: AB394EC1C2983363B045EE16 --- Logging error --- Traceback (most recent call last): File "{fakepath}\env\lib\logging\__init__.py", line 992, in emit msg = self.format(record) File "{fakepath}\env\lib\logging\__init__.py", line 838, in format return fmt.format(record) File "{fakepath}\env\lib\logging\__init__.py", line 575, in format record.message = record.getMessage() File "{fakepath}\env\lib\logging\__init__.py", line 338, in getMessage msg = msg % self.args TypeError: not all arguments converted during string formatting Call stack: File "{fakepath}\pnl_calculator\main_pnl_worker.py", line 109, in run result_list = main(self.fd, self.td, self.book) File "{fakepath}\pnl_calculator\main_pnl_worker.py", line 67, in main start_price_dict = tr_api.get_tr_price(time_interval['from_time_divisa'].date()) File "{fakepath}\pnl_calculator\util.py", line 31, in timed result = method(*args, **kw) File "{fakepath}\pnl_calculator\tr_api.py", line 45, in get_tr_price req, error = ek.get_data(symbol_ric, parameters={'SDate':f'{date}', 'EDate':f'{date}'}, fields=['TR.ASKPRICE','TR.BIDPRICE'], debug=True) File "{fakepath}\env\lib\site-packages\eikon\data_grid.py", line 151, in get_data result = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug) File "{fakepath}\env\lib\site-packages\eikon\json_requests.py", line 49, in send_json_request logger.debug("entity: ", entity) Message: 'entity: ' Arguments: ('DataGrid',) 2018-03-29 11:42:42,452 - DEBUG - payload: 2018-03-29 11:42:42,452 - DEBUG - Request: {"Entity": {"E": "DataGrid", "W": {"instruments": ["AUDCAD=", "AUDCHF=", "AUDJPY=", "AUDNZD=", "AUD=", "CADCHF=", "CADJPY=", "CHFJPY=", "EURAUD=", "EURCAD=", "EURCHF=", "EURGBP=", "EURJPY=", "EURNZD=", "EUR=", "GBPAUD=", "GBPCAD=", "GBPCHF=", "GBPJPY=", "GBPNZD=", "GBP=", "NZDCAD=R", "NZDCHF=R", "NZDJPY=", "NZD=", "CAD=", "CHF=", "JPY="], "fields": [{"name": "TR.ASKPRICE"}, {"name": "TR.BIDPRICE"}], "parameters": {"SDate": "2018-03-28", "EDate": "2018-03-28"}}}, "ID": "123"} 2018-03-29 11:43:01,556 - DEBUG - http://localhost:9000 "POST /api/v1/data HTTP/1.1" 200 65 2018-03-29 11:43:01,557 - INFO - HTTP Response: 200 - {"ErrorCode":400,"ErrorMessage":"Backend error. 400 Bad Request"} 2018-03-29 11:43:01,557 - ERROR - Backend error. 400 Bad Request Traceback (most recent call last): File "{fakepath}\pnl_calculator\tr_api.py", line 45, in get_tr_price req, error = ek.get_data(symbol_ric, parameters={'SDate':f'{date}', 'EDate':f'{date}'}, fields=['TR.ASKPRICE','TR.BIDPRICE'], debug=True) File "{fakepath}\env\lib\site-packages\eikon\data_grid.py", line 151, in get_data result = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug) File "{fakepath}\env\lib\site-packages\eikon\json_requests.py", line 87, in send_json_request check_server_error(result) File "{fakepath}\env\lib\site-packages\eikon\json_requests.py", line 135, in check_server_error raise requests.HTTPError(error_message, response=server_response) requests.exceptions.HTTPError: Backend error. 400 Bad Request

Answers

  • @yikang

    Thank you for reporting this issue. I have reproduced and escalated it. I will post on this thread as soon as I hear back from the resolver team. As an immediate workaround you can retrieve yesterday's closing bid and ask rates for FX RICs using CLOSE_BID and CLOSE_ASK fields, e.g.

    ek.get_data(symbol_ric, fields=['CLOSE_BID','CLOSE_ASK'])
  • thanks, the close_bid works.

  • I also have the same problem starting yesterday........

  • So right now the TR.ASK and TR.BID is working, but no matter what SDATE and EDATE i post to the request for ['CLOSE_BID','CLOSE_ASK'], it will give me todays data. any thoughts on that?

    ek.get_data('JPY=', parameters={'SDate':'2018-03-01', 'EDate':'2018-04-01'},fields=['CLOSE_BID','CLOSE_ASK'], debug=True)
  • CLOSE_BID and CLOSE_ASK fields can only provide bid/ask rates as of yesterday's close. SDate and EDate parameters are not applicable to these fields and are ignored in the request. In general field names that do not start with TR.* come from the real-time data stream and do not provide timeseries of history.

  • ok, only found out that today. I will keep using TR.askprice and TR.bidprice since it was fixed(I assume?)

  • We identified one possible source of the problem, but not yet sure if this was indeed the root cause. We're still continuing the investigation.