Back to Community
ROE N days ago not working bug

In research notbook, I am trying to get ROE data N days ago. But "morningstar" data does not work as expected.

My example shows "ROE_today" and "ROE_yesterday" comparsion. I would expect they have N-1 row shift difference, but you can see, they are the same(which is wrong).

Interestingly, in my example, if you change N to larger number (like 252), ROE seems working. However, smaller number won't work.

"Fundamentals" PE data seems working as intend, but not "morningstar" ROE data. Look carefully of the print data and you will see what I am trying to say.

Thanks,
Ray

Loading notebook preview...
Notebook previews are currently unavailable.
7 responses

The Return On Equity (ROE) field is calculated from

Net Income / Average Total Common Equity

The income and equity values are based upon quarterly reports and are trailing twelve month (TTM) values. Net income is the bottom-line profit, before common-stock dividends are paid, reported on a firm’s income statement. Common equity is assets minus liabilities reported on a firm's balance sheet. It is the accounting value that's left for shareholders in the event a company settled its liabilities with its reported assets. Both of these values are obtained from quarterly reports.

Because ROE is calculated from quarterly report data it generally will only change quarterly. This is why ROE today is almost always the same as ROE N days ago. It will generally only change when a new, or updated, quarterly report is issued.

The Price Earnings ratio (PE) field is calculated from

Adjusted Close Price / Earnings per Share (EPS)

The EPS value is based upon quarterly reports and are trailing twelve month (TTM) values. It will generally only change quarterly. However, the close price will change daily. Therefore, one typically sees the PE value change daily. This is why PE today is almost never the same as PE N days ago.

Your 'Roe_yesterday' custom factor is working properly and isn't a bug. Hope that makes sense.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thank you for the reply.

However, focus on ROE 11-13, 11-14. You can see ROE_today changed. So we know there is a new quarter report on apple. But next day 11-17 Roe_yesterday does not change as expected.

Thanks,
Ray

I explain it wrong. I don’t expect ROE and ROE_yesterday changed at same time on 2003-11-14. I expect ROE_yesterday have 1 day delay.

Thanks,
Ray

@Rui Cui Great observation. Welcome to the world of fundamentals where there is often a lag between the asof_date and the reporting or timestamp date. Quantopian only surfaces information which would have been known at the time.

Yes, it appears AAPL released 3rd qtr results on 11-14-2003. Only when a quarterly report is released do we know what the data was for a particular quarter. When this data was first available to Quantopian is the timestamp. The timestamp for the 3rd qtr results was 11-14-2003. However, once it is released, we know the values all the way back to the end of the quarter or the asof_date.

There are really two questions one can ask about previous ROE data:

  • "What was the ROE N days ago, knowing everything we know through today?"*
  • "What would someone have said the ROE was N days ago, only knowing what was available N days ago?"*

Those are two different questions and have two different use cases. Quantopian can answer both of them.

To answer the first question one needs to find the value of the data N days ago as of today. That is the value we see in the data above. Both the values for ROE_today and ROE_yesterday change on 11-14. This is because, now that results were released, we also know yesterday's actual ROE. Before that, the latest ROE we had was from the previous quarter. So, on 11-14 all previous ROE values back to the asof_date are now known and are now changed to reflect the new value.

To answer the second question one needs to find the value of the factor N days ago. There is a pretty good post on this here (https://www.quantopian.com/posts/get-lagged-output-of-pipeline-custom-factor). You may also want to look at these two sections of the documentation for info on Quantopian's 'point-in-time' data.

https://www.quantopian.com/docs/data-reference/overview#point-in-time-data-reference
https://www.quantopian.com/docs/data-reference/factset_fundamentals#factset-fundamentals-date-columns

Attached is a notebook which shows these two different ways of capturing previous data. It also shows how one can look at the asof_date and timestamp fields for when the fundamental data field applies and when it was first surfaced respectively.

Hope that helps.

Loading notebook preview...
Notebook previews are currently unavailable.

I understand the two different question you brought up and I see where you are going. But I would still give the same result of the two questions. I also appreciate the quick response.

But I would still think this is an issue for me, although I have other way to bypass this issue.

Thanks,
Ray

@Rui Cui What are you trying to do? Are you looking for changes in ROE? When ROI_today is different than ROI_yesterday? If that's the case then pass the ROI factor to the 'Value_N_Days_Ago' factor. There is also a post about that here (https://www.quantopian.com/posts/change-in-fundamental-data-in-research) which may help.

Hello Dan,

No, I will abandon the methodology to use any factor with "N days ago" (factors as input X). I will shift my output Y "N days later".

Thanks,
Ray