Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
EPS TTM

I am trying to calculate the trailing twelve month EPS , some reason the EPS calculated using adding the EPS by quarters or by creating the eps only the fly using balance data doesn't match the TTM eps calculated by yahoo or other sites. What am I doing wrong?

7 responses

Working with fundamentals has a number of subtleties and, for me, is a never ending source of consternation.

I'm not sure specifically why you feel the TTM eps data on Q is different than other sources, but, here are a few things to consider...

Make certain one chooses the correct fields in the fundamental data and understand what other sources are using. Most other sources such as Yahoo and NASDAQ report the "diluted earnings per share". This corresponds with the fundamental field "Fundamentals.diluted_eps_earnings_reports".

Also, (and this is a big one) Quantopian goes to great lengths to ensure no forward looking bias in it's data. The data returned by pipeline is only the data which would have been known on the date the pipeline is run. This is generally pretty straight forward when accessing price and volume data, but fundamental data adds several levels of complexity. First, there is the issue that companies report fundamental data after the fact. The Securities & Exchange Commission (SEC) requires companies to file earnings reports no later than 45 days after the end of their first three quarters, and their quarterly and annual reports 90 days after their fiscal year (thank you Investopedia). What does that mean? Take AAPL for instance. It reported 12-31-2017 earnings on 2-2-2018. Moreover, Morningstar didn't enter it until the following business day 2-5-2018 so the soonest one would see it in pipeline is when run on 2-6-2018. When fetching the 'latest' eps on 2-5-2018 one would get the Q3 2017 results. The next day, 2-6-2018, one would get the Q4 results.

What makes this more frustrating is companies report their results on different days. For example TSLA reported earnings on 2-7-2018. Additionally, Morningstar doesn't always update their data in a timely manner (as of 2-18-2018 the latest eps for TSLA still was for Q3 2017). Now, add on top of this the reality that companies are often restating data. A company's Q4 results can change over time. Arghhhh.

What does this mean. Simply put, the following does NOT work to get the previous "Trailing Twelve Months" (TTM) of data.

TRADING_DAYS_IN_YEAR=252  
qtr = TRADING_DAYS_IN_YEAR / 4


class TTM_DATA(CustomFactor):  
    window_length=TRADING_DAYS_IN_YEAR  
    def compute(self, today, asset_ids, out, data):  
        out[:] = eps[-1] + eps[-1*qtr] + eps[-2*qtr] + eps[-3*qtr]

Consider the the case of AAPL. If one runs this custom factor on 2-5-2018, the 2017 Q3 data would get added twice and the 2017 Q4 data wouldn't be available. Only when run on 2-6-2018 would it be correct. The most reliable way to get TTM data is to also check the "asof_date". @Doug Baldwin has a nice custom factor for this ( see https://www.quantopian.com/posts/trailing-twelve-months-ttm-with-as-of-date ).

Maybe also check these excellent posts
https://www.quantopian.com/posts/faster-fundamental-data
https://www.quantopian.com/posts/quantopian-partner-data-how-is-it-collected-processed-and-surfaced

I hope this can be helpful rather than discouraging or overwhelming, there's overlap in these sections.
With Dan's comments noted, one that I've found interesting in results with my particular type backtest is normalized_diluted_eps_earnings_reports, also normalized_basic_eps_earnings_reports

Others and more info. Do watch out for fundamentals that mostly return nans.

Related to diluted_eps_earnings_reports mentioned above
basic_continuous_operations_earnings_reports
basic_eps_earnings_reports
continuing_and_discontinued_diluted_eps_earnings_reports
diluted_eps_earnings_reports
normalized_basic_eps_earnings_reports
normalized_diluted_eps_earnings_reports
tax_loss_carryforward_basic_eps_earnings_reports
tax_loss_carryforward_diluted_eps_earnings_reports

All containing earnings
basic_accounting_change_earnings_reports
basic_average_shares_earnings_reports
basic_continuous_operations_earnings_reports
basic_discontinuous_operations_earnings_reports
basic_eps_earnings_reports
basic_eps_other_gains_losses_earnings_reports
basic_extraordinary_earnings_reports
continuing_and_discontinued_basic_eps_earnings_reports
continuing_and_discontinued_diluted_eps_earnings_reports
diluted_accounting_change_earnings_reports
diluted_average_shares_earnings_reports
diluted_continuous_operations_earnings_reports
diluted_discontinuous_operations_earnings_reports
diluted_eps_earnings_reports
diluted_eps_other_gains_losses_earnings_reports
diluted_extraordinary_earnings_reports
dividend_per_share_earnings_reports
earnings_from_equity_interest
earnings_losses_from_equity_investments
earningsfrom_equity_interest_net_of_tax
gains_losses_not_affecting_retained_earnings
normalized_basic_eps_earnings_reports
normalized_diluted_eps_earnings_reports
retained_earnings
tax_loss_carryforward_basic_eps_earnings_reports
tax_loss_carryforward_diluted_eps_earnings_reports
total_dividend_per_share_earnings_reports

All EPS
continuing_and_discontinued_diluted_eps_earnings_reports
diluted_eps_earnings_reports
basic_eps_earnings_reports
continuing_and_discontinued_basic_eps_earnings_reports
normalized_basic_eps_earnings_reports
normalized_diluted_eps_earnings_reports
tax_loss_carryforward_basic_eps_earnings_reports
diluted_cont_eps_growth
basic_eps_other_gains_losses_earnings_reports
diluted_eps_other_gains_losses_earnings_reports
diluted_eps_growth
basic_eps
basic_eps_other_gains_losses
continuing_and_discontinued_basic_eps
continuing_and_discontinued_diluted_eps
diluted_eps
diluted_eps_other_gains_losses
normalized_basic_eps
normalized_diluted_eps
tax_loss_carryforward_basic_eps
tax_loss_carryforward_diluted_eps
tax_loss_carryforward_diluted_eps_earnings_reports

Dan, thank you for the excellent explanation and link to TTM custom factor by @Doug Baldwin. Using the new custom factor most of the symbols produced similar eps number corresponding to yahoo finance or guru focus. But some of them are way of with the number, even with a different date period. For example, (AXP) the EPS calculated at Quantopian research is 5.2 where as the reported eps in yahoo finance and guru focus is 2.9 for the same time period.

@Boney, TTM is for absolute quantities only, e.g. revenue, cost of goods sold, net income. Your counter-example of earnings per share (EPS) is a ratio, and summing the four quarters would be accurate only for those stocks that have no change in outstanding shares over the prior four quarters. So, to calculate TTM EPS, you might try: ( TTM Net Income - TTM Dividends on Preferred Stock ) / Latest number of Common Shares Outstanding. For shares outstanding, you have that reported quarterly, but if a stock split mid-quarter, the number would be inaccurate.

@Doug, I tried your calculation, still the number didn't change that much, I even checked the stock split history and didn't find any split for American Express in recent months.Stock split history for AXP

@Boney. The ground truth is found in 10-K/Q financial statements. I find it very useful to compare a sample of questionable Fundamental Data against financial statements. Morningstar data is only as good as the accuracy of their data entry clerk and data quality process. Furthermore, I have detected differences in fundamental data reporting between Quantopian's Morningstar data and the Morningstar website. You may determine that this particular data element, EPS, is not reliable enough for your needs. Some are more reliable than others.

In QTU, number of companies whose reports reached us per date during one year for the top 20, for total_revenue, and the code.
The numbers for total_revenue and diluted_eps_earnings_reports are similar though not identical.

2017-12-29 13:00 logging:128 INFO 231 dates  counts: max 503  min 1  mean 35  median 11.0  
2017-03-01    158                            2017-08-01    195  
2017-03-02    132                            2017-08-07    165  
2017-03-03    203                            2017-08-08    503  <== high  
2017-03-06    162                            2017-08-10    151  
                                             2017-08-11    178  
2017-05-02    211  
2017-05-05    138                            2017-10-31    132  
2017-05-08    131                            2017-11-06    210  
2017-05-09    351                            2017-11-07    289  
2017-05-11    144                            2017-11-13    178  
2017-05-12    149                            2017-11-14    301  

Only one company for 20+ dates like 2017-07-20.