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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
7 2 0 4

Python API error 400 for same set of data that works in Excel

Excel formula that pulls data (EPS numbers) as expected:

=TR("SCREEN(U(IN(Equity(active,public,primary))),avail(TR.EPSEstValue(Period=FY1,Brokers=US_3202),TR.EPSEstValue(Period=FY1,Brokers=US_63721),TR.EPSEstValue(Period=FY1,Brokers=US_63725))>=-100)","TR.PrimaryRIC","avail(TR.EPSEstValue(Period=FY1,Brokers={US_3202}),TR.EPSEstValue(Period=FY1,Brokers={US_63721}),TR.EPSEstValue(Period=FY1,Brokers={US_63725}))")

Python Web script API that error 400 Bad Request consistently:

df, err = ek.get_data(['SCREEN(U(IN(Equity(active,public,primary))),avail(TR.EPSEstValue(Period=FY1,Brokers=US_3202),TR.EPSEstValue(Period=FY1,Brokers=US_63721),TR.EPSEstValue(Period=FY1,Brokers=US_63725))>=-100)'], ['TR.PrimaryRIC','avail(TR.EPSEstValue(Period=FY1,Brokers={US_3202}),TR.EPSEstValue(Period=FY1,Brokers={US_63721}),TR.EPSEstValue(Period=FY1,Brokers={US_63725}))'])

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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.

Upvotes
Accepted
38.1k 71 35 53

I have contacted the development team and found that it returns 400 Bad Request because of timeout. The SCREEN function is complex and takes a lot of time to be processed so it can be timeout.

As I know, Equity Screener is available but not yet supported through Eikon Data API.

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.

Upvotes
38.1k 71 35 53

It looks like that the second parameter (fields) of get_data doesn't support the avail function. It works if I remove the avail function.

df, err = ek.get_data(['SCREEN(U(IN(Equity(active,public,primary))),avail(TR.EPSEstValue(Period=FY1,Brokers=US_3202),TR.EPSEstValue(Period=FY1,Brokers=US_63721),TR.EPSEstValue(Period=FY1,Brokers=US_63725))>=-100)'], 
                      ['TR.PrimaryRIC','TR.EPSEstValue(Period=FY1,Brokers=US_3202)','TR.EPSEstValue(Period=FY1,Brokers=US_63721)','TR.EPSEstValue(Period=FY1,Brokers=US_63725)'])

However, the application needs to remove the value which is NaN.


df.png (15.0 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.

Thanks for the help. The problem is that the following screen formula uses avail() and it works:

SCREEN(U(IN(Equity(active,public,primary))), avail(TR.EPSEstValue(Period=FY1,Brokers=US_2),TR.EPSEstValue(Period=FY1,Brokers=US_57030))>=-100,)

So I don't think avail() is the problem.

I have tested this again and found that the result is inconsistent. Sometimes, it works.

Others return "400 Bad Request".

I will contact the product team to verify the problem.

works.png (16.1 KiB)
badrequest.png (35.1 KiB)

Thank you, Jirapongse. I really appreciate your help

Click below to post an Idea Post Idea