Overall Statistics |
Total Trades 79 Average Win 5.15% Average Loss -2.75% Compounding Annual Return 14.586% Drawdown 44.900% Expectancy 0.642 Net Profit 61.077% Sharpe Ratio 0.484 Probabilistic Sharpe Ratio 12.860% Loss Rate 43% Win Rate 57% Profit-Loss Ratio 1.87 Alpha 0.164 Beta 0.07 Annual Standard Deviation 0.355 Annual Variance 0.126 Information Ratio 0.166 Tracking Error 0.372 Treynor Ratio 2.465 Total Fees $766.18 |
# https://quantpedia.com/Screener/Details/25 class SmallCapInvestmentAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2016, 1, 1) self.SetEndDate(2019, 7, 1) self.SetCash(100000) self.year = -1 self.count = 10 self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction) def CoarseSelectionFunction(self, coarse): ''' Drop stocks which have no fundamental data or have low price ''' if self.year == self.Time.year: return Universe.Unchanged return [x.Symbol for x in coarse if x.HasFundamentalData and x.Price > 5] def FineSelectionFunction(self, fine): ''' Selects the stocks by lowest market cap ''' sorted_market_cap = sorted([x for x in fine if x.MarketCap > 0], key=lambda x: x.MarketCap) return [x.Symbol for x in sorted_market_cap[:self.count]] def OnData(self, data): if self.year == self.Time.year: return self.year = self.Time.year for symbol in self.ActiveSecurities.Keys: self.SetHoldings(symbol, 1/self.count) def OnSecuritiesChanged(self, changes): ''' Liquidate the securities that were removed from the universe ''' for security in changes.RemovedSecurities: symbol = security.Symbol if self.Portfolio[symbol].Invested: self.Liquidate(symbol, 'Removed from Universe')