Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0.935 Tracking Error 0.092 Treynor Ratio 0 Total Fees $0.00 |
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)