Hi There. I'm trying to run the following using pycharm IDE (python 2.7). I however get a "400 Ba...
...d Request" error as per below. This error does not always occur, sometimes the exact same script runs fine. Please advise.
My Script:
df, err = ek.get_data(000001.SZ,000002.SZ,000030.KS,000039.SZ,000050.SZ,
TR.PriceClose.calcdate;
TR.EPSActValue(Period=FY - 3);
TR.EPSActValue(Period=FY - 2);
TR.EPSActValue(Period=FY - 1);
TR.EPSActValue(Period=FY0);
TR.EPSMean(Period=FY1);
TR.EPSMean(Period=FY2);
TR.EPSMean(Period=FY3);
TR.NumberOfAnalysts(Period=FY - 3);
TR.NumberOfAnalysts(Period=FY - 2);
TR.NumberOfAnalysts(Period=FY - 1);
TR.NumberOfAnalysts(Period=FY0);
TR.NumberOfAnalysts(Period=FY1);
TR.NumberOfAnalysts(Period=FY2);
TR.NumberOfAnalysts(Period=FY3);
TR.EPSMean(Period=FY - 3).periodenddate;
TR.EPSMean(Period=FY - 2).periodenddate;
TR.EPSMean(Period=FY - 1).periodenddate;
TR.EPSMean(Period=FY0).periodenddate;
TR.EPSMean(Period=FY1).periodenddate;
TR.EPSMean(Period=FY2).periodenddate;
TR.EPSMean(Period=FY3).periodenddate
,SDate=2017-01-01,EDate=2017-03-31,Frq=M)
Error I get:
Traceback (most recent call last):
File "/Users/richardtbenade/Repos/df_001/datapull.py", line 71, in <module>
df, err = ek.get_data(instrument_list_batch[k],get_command_string)
File "/Users/richardtbenade/virtualenvs/eikon/lib/python2.7/site-packages/eikon/data_grid.py", line 141, in get_data
result = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug)
File "/Users/richardtbenade/virtualenvs/eikon/lib/python2.7/site-packages/eikon/json_requests.py", line 82, in send_json_request
check_server_error(result)
File "/Users/richardtbenade/virtualenvs/eikon/lib/python2.7/site-packages/eikon/json_requests.py", line 130, in check_server_error
raise requests.HTTPError(error_message, response=server_response)
requests.exceptions.HTTPError: 400 Bad Request
Process finished with exit code 1
Best Answer
-
@Jan
I'm afraid the method you're executing doesn't make sense to me on more than one level.
The request example you provided has so many syntax errors, I don't see how it can possibly ever run fine. I have to assume that somehow the text must have been altered in transfer between IDE and your post here? Otherwise you'd be getting syntax errors instead of HTTP 400.
Semantically why do you want to mix the last business day of the month between January and March 2017 (provided by TR.PriceClose.calcdate with {'SDate':'2017-01-01','EDate':'2017-03-31','Frq':'M'} parameters) with EPS estimates for the previous and the next 3 years? But assuming for whatever reason this is indeed what you want to retrieve, the correct syntax is:df, err = ek.get_data(['000001.SZ','000002.SZ','000030.KS','000039.SZ','000050.SZ'], ['TR.PriceClose.calcdate', 'TR.EPSActValue(Period=FY-3)', 'TR.EPSActValue(Period=FY-2)', 'TR.EPSActValue(Period=FY-1)', 'TR.EPSActValue(Period=FY0)', 'TR.EPSMean(Period=FY1); TR.EPSMean(Period=FY2)', 'TR.EPSMean(Period=FY3)', 'TR.NumberOfAnalysts(Period=FY-3)', 'TR.NumberOfAnalysts(Period=FY-2)', 'TR.NumberOfAnalysts(Period=FY-1)', 'TR.NumberOfAnalysts(Period=FY0)', 'TR.NumberOfAnalysts(Period=FY1)', 'TR.NumberOfAnalysts(Period=FY2)', 'TR.NumberOfAnalysts(Period=FY3)', 'TR.EPSMean(Period=FY-3).periodenddate', 'TR.EPSMean(Period=FY-2).periodenddate', 'TR.EPSMean(Period=FY-1).periodenddate', 'TR.EPSMean(Period=FY0).periodenddate', 'TR.EPSMean(Period=FY1).periodenddate', 'TR.EPSMean(Period=FY2).periodenddate', 'TR.EPSMean(Period=FY3).periodenddate'],{'SDate':'2017-01-01','EDate':'2017-03-31','Frq':'M'})
I noticed in your example you have white spaces in some of the field level parameters, e.g. there are two spaces in TR.NumberOfAnalysts(Period=FY - 3). Not sure of you had them in your script, but these spaces will certainly result in HTTP 400 error.
0
Answers
-
Hi @Jan,
Would it be possible on your side to retest with Python 3.6?
I can not be sure about this specific issue, but find that some unexpected behaviors stop manifesting with py 3.6.
Thanks
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 687 Datastream
- 1.4K DSS
- 622 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 680 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 91 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛