Overall Statistics |
Total Trades 127 Average Win 1.46% Average Loss -1.73% Compounding Annual Return -22.980% Drawdown 19.000% Expectancy -0.061 Net Profit -10.365% Sharpe Ratio -0.489 Probabilistic Sharpe Ratio 14.127% Loss Rate 49% Win Rate 51% Profit-Loss Ratio 0.84 Alpha -0.155 Beta 0.086 Annual Standard Deviation 0.316 Annual Variance 0.1 Information Ratio -0.429 Tracking Error 0.382 Treynor Ratio -1.788 Total Fees $2025.02 |
# Compounding Annual Return: 23.624% class PERatioStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2000, 1, 1) # Set Start Date self.SetEndDate(2000, 6, 1) # Set End Date self.SetCash(100000) # Set Strategy Cash self.Settings.FreePortfolioValuePercentage = 0.1 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 self.symbols CoarseWithFundamental = [x for x in coarse if x.HasFundamentalData and x.Price > 5] sortedByDollarVolume = sorted(CoarseWithFundamental, key=lambda x: x.DollarVolume, reverse=False) return [i.Symbol for i in sortedByDollarVolume[:500]] def FineFilter(self, fine): if self.Time.month == self.lastMonth: return self.symbols self.lastMonth = self.Time.month fine = [x for x in fine if x.ValuationRatios.PERatio > 0] sortedPERatio = sorted(fine, key=lambda x: x.ValuationRatios.PERatio) self.symbols = [x.Symbol for x in sortedPERatio[:10]] return self.symbols def OnSecuritiesChanged(self, changes): holdings = [] for symbol in self.symbols: holdings.append(PortfolioTarget(symbol, 0.1)) # self.Liquidate() self.SetHoldings(holdings, True) def Summary(self): self.Debug(self.Time) # holdings = [] # for symbol in self.Portfolio.Keys: # holding = self.Portfolio[symbol] # positionSize = holding.Quantity * holding.Price # temp = f'{symbol.Value}:{positionSize}' # holdings.append(temp) # self.Debug(' '.join(holdings)) self.Debug(f'{self.Portfolio.Cash}, {self.Portfolio.UnsettledCash}') self.Debug(f'{self.Portfolio.MarginRemaining}, {self.Portfolio.TotalMarginUsed}') self.Debug(f'{self.Portfolio.TotalHoldingsValue}, {self.Portfolio.TotalPortfolioValue}')