Overall Statistics
class PERatioStrategy(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2005, 1, 1)  # Set Start Date
        self.SetEndDate(2005, 4, 1)  # Set End Date
        self.SetCash(100000)  # Set Strategy Cash
        
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.CoarseFilter, self.FineFilter)
        self.lastMonth = -1
        self.symbols = []
    
    
    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[:50]]
        
    
    def FineFilter(self, fine):
        if self.Time.month == self.lastMonth:
            return Universe.Unchanged
        self.lastMonth = self.Time.month
        
        self.Log(f'fine {[x.ValuationRatios.ForwardPERatio for x in fine]}')
        fine = [x for x in fine if x.ValuationRatios.ForwardPERatio > 0]
        fine = sorted(fine, key=lambda x: x.ValuationRatios.ForwardPERatio, reverse=False)
        self.symbols = [x.Symbol for x in fine[:5]]
        return self.symbols
    
    
    def OnSecuritiesChanged(self, changes):
        self.Liquidate()
        for symbol in self.symbols:
             self.SetHoldings(symbol, 0.04)