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}))'])

Best Answer

  • 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.

Answers

  • 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.

    image

  • 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.

    image

    Others return "400 Bad Request".

    image

    I will contact the product team to verify the problem.

  • Thank you, Jirapongse. I really appreciate your help