Earnings release dates & period end dates in 1 request?

date , err = ek.get_data(["KGC.N"], ["TR.EventType(EventType=RES).date", "TR.EventType(EventType=RES).companyevent"], {'SDate':'2010-01-01', 'EDate':today})

I'm trying to get Earning Release dates historically, which is achievable using the above command. However, I wish to also have the associate end of quarter for each earnings release as an additional column. I consulted Eikon Excel support and they provided me with:

=TR("AAPL.OQ","TR.EventType;TR.EventType.date;TR.PreferredMeasureActValue.periodenddate","SDate=2016-01-01 EDate=-1W EventType=RES Frq=FQ Period=FQ0 CH=Fd RH=IN",B6)

This return exactly what I want in Excel by tying the period end date which TR recieved an Actual to the earning release date. I'm sure it is possible within the API, but I'm struggling to replicate.

Best Answer

  • Alex Putkov.1
    Answer ✓

    get_data method has very similar syntax to =TR Excel worksheet function. The first argument is instruments, the second is field names, the third is parameters. The difference is that in Excel the values of the arguments are strings or cell references, in Python they are lists and dictionaries. There are also subtle differences like RH and CH formatting parameters, which control what is returned as row and column headers in the resulting table, are only supported in Excel. get_data method ignores these parameters. But overall, if you have an =TR function, it's pretty straightforward to replicate it using get_data method.
    Here's the get_data call equivalent to =TR function you were given

    ek.get_data(['AAPL.OQ'],['TR.EventType','TR.EventType.date','TR.PreferredMeasureActValue.periodenddate'],{'SDate':'2016-01-01','EDate':
    '-1W','EventType':'RES','Frq':'FQ','Period':'FQ0'})

Answers

  • Note that I defined 'today' using:

    import time as t
    today = t.strftime("%Y-%m-%d")
  • Thank you! I've had trouble before combining more than one field, so that explanation and call structure is very helpful