Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
pe_ratio data is not right?

I tried several stocks which are losing money every year, but their pe_ratio is all positive and not "None".

Is this a bug? Or problem in the data?

See the "JCP" below, it happens to "SHLD" as well.

JCP:market_cap 2274195718
tangible_book_value 2.43e+09
pe_ratio 40.3226
basic_eps -0.62
primary_symbol JCP
dividend_yield 0.0122
current_ratio 1.768924
morningstar_sector_code 102

11 responses

Also, for JCP, there was no dividend for 2 years now, the basic EPS is also quite different from -$0.62.

I found there may be a bug with the fundamental data. It seems that one a value changes from some "not None" value to "None", it will not change to "None", but simply inherit last year's number.

For example, if last year's earning is positive, and this year's earning is negative, the pe_ratio will not be None, but instead stay the same with the last year. The same thing happened to "dividend" and "net_debt".

Can someone fix this bug, since it is pretty serious?

Mingran,

Thanks for posting. I'm looking into it. In the meanwhile can you show me how you found that bug for dividend and net_debt? E.g. which securities over which time frame.

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.

JCP's dividend was suspended many years ago, but it still shows 1.22% dividend yield right now.

For net_debt, I forgot which symbol had it, but it should not be that hard to find. When a company changes from net debt to "no net debt", this bug might happen.

All the three problems may be caused by the same bug: inheriting non-"None" value from previous years.

Hmm if this bug is as it sounds, a heads-up when it's fixed would be appreciated, to rerun fundamentals-based backtests!

Any update on this bug? I found another example. LQDT says it has pe_ratio of 9.5147 but they lost money over the past 12 months. Looks like that was the pe ratio just before they reported a big loss. So that pe ratio got left there when it should've been changed to "None".

However, one thing I noticed was it seems right for ev_to_ebitda, as that correctly reports -5.0151.

Hi, we have this one in our queue. We fixed a bunch of fundamentals data issues last month but this wasn't one of them :(

Hopefully this one makes it into the next batch.

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.

I just bumped into an issue quite similar to this one and I wonder if any progress has been made? Is this issue still on your radar?

yes, and there are many missing values too. and some values just don't seem right.
if you get pe_ratio for VRX(10908), you will see from May to Oct 2016 it remain constant..

I'm guessing this must not be a priority issue for the Quantopian team. Anyone have useful workarounds for getting decent PE data?

Hi Chris, I have fixed this issue by creating PERatio CustomFactor, where I manually calculated PE ratio from current close price and trailing 12-months EPS. I then compared the results with Morningstar data for the correct dates and they were pretty close. See the notebook for more details.

In short, you need to add the following code:

def get_periodic(df, periods, interval_days=252):  
    """ Get periodic data  
    df: DataFrame object.  
    periods(int): Number of periods to go back for.  
    interval_days(int): Number of trading days, default to 252 (one year).  
    """  
    idx = [-1]  
    for i in range(1, periods):  
        idx.append(-i * interval_days)  
    idx.reverse()  
    periodic_data = df[idx]  
    return periodic_data  
class PERatio(CustomFactor):  
    inputs = [USEquityPricing.close,  
              Fundamentals.diluted_eps_earnings_reports]  
    outputs = ['pe', 'close', 'eps']  
    quarter_days = 252/4  
    quarters = 5  
    window_length = quarter_days*quarters  
    def compute(self, today, assets, out, close, eps):  
        close_p = get_periodic(close, self.quarters, interval_days=self.quarter_days)  
        eps_p = get_periodic(eps, self.quarters, interval_days=self.quarter_days)

        # For each company  
        for i in range(close_p.shape[1]):  
            uniq_eps_ids = np.unique(eps_p[:,i], return_index=True)[1]  
            uniq_eps = [eps_p[index, i] for index in sorted(uniq_eps_ids)]  
            out.close[i] = close_p[-1, i]  
            out.eps[i] = np.sum(uniq_eps[-4:])  
            out.pe[i] = close_p[-1, i] / out.eps[i]  

And to use it simply do as follows

pe_ratio = PERatio()  

Then add pe_ratio.eps in your pipeline.

Would appreciate more testing if anyone's available.