Hi everyone. I would like to find stocks that have negative PE ratios. For somereason, my current implementation returns an empty universe. Can someone please explain what I am doing wrong? Thank you!
def CoarseFilter(self, coarse):
if self.Time.month == self.lastMonth:
return Universe.Unchanged
course = [x for x in coarse if x.HasFundamentalData and x.DollarVolume > 10000000]
course = sorted(course, key=lambda x: x.DollarVolume, reverse=False)
return [i.Symbol for i in course[:500]]
def FineFilter(self, fine):
if self.Time.month == self.lastMonth:
return Universe.Unchanged
self.lastMonth = self.Time.month
fine = [x for x in fine if x.ValuationRatios.PERatio < 0]
fine = sorted(fine, key=lambda x: x.ValuationRatios.PERatio, reverse=True)
self.symbols = [x.Symbol for x in fine[:25]]
return self.symbols
Rahul Chowdhury
Hey Michael,
ValuationRatios.PERatio in Lean is set to null if it is less than or equal to 0. You can learn more about this by searching for "ValuationRatios/PERatio" in the documentation on fundamental data. One way to to work around this is to import PERatio data from another source as custom data. You can then use that data in your algorithm to create trading signals.
Best
Rahul
Michael Boguslaw
Why is it null if it is negative? Is a negative PE ratio not a valuable piece of information? (I am knew to fundamentals so I am unsure).
Could I approximate the pe ratio with: EarningsReports.NormalizedDilutedEPS / hist.loc[str(x.Symbol)]['close'][0] ?
Do you recommend any other fundamentals to check for stocks with negative earnings?
Rahul Chowdhury
Hi Michael,
EarningsReports.NormalizedDilutedEPS is a good choice to approximate EPS, but I would suggest you experiment with other EPS fundamental data, like BasicEPS and others. You can filter for the securities with negative EPS and then calculate the PERatio for only the securities with negative PERatio.
Best
Rahul
Michael Boguslaw
I am trying to recreate the PERatio formula the way it is implemented by QuantConnect in fine.ValuationRatios.PERatio. I tried using the formula fine.Price / fine.EarningReports.BasicEPS.OneYear, but I am getting a different result. What values should I use to best match fine.ValuationRatios.PERatio?
Rahul Chowdhury
Hi Michael,
The ValuationRatios.PERatio we provide is not calculated by QuantConnect using any specific metric, but rather directly provided by our data source Morningstar. According to Morningstar, the PERatio they provide is calculated by dividing the stock price by the EPS from continuing operations.
EarningReports provide ContinuingAndDiscontinuedBasicEPS and ContinuingAndDiscontinuedDilutedEPS,
which you can use in your calculations.
I would suggest experimenting with different EPS metrics like BasicEPS, DilutedEPS, NormalizedBasicEPS, etc, to find the PERatio calculation which best suits your needs. You can find a full list of metrics in the EarningReports file.
Best
Rahul
Michael Boguslaw
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!