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.706 Tracking Error 0.108 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class CryingVioletKitten(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 11, 1) self.SetEndDate(2021, 11, 30) self.SetCash(100000) self.AddUniverse(self.MyCoarseFilterFunction) self.symbolDataBySymbol = {} def MyCoarseFilterFunction(self,coarse): StocksUnder10 = [c.Symbol for c in coarse if c.Price < 10] return StocksUnder10 def OnSecuritiesChanged(self, changes): for security in changes.AddedSecurities: symbol = security.Symbol if symbol not in self.symbolDataBySymbol: self.symbolDataBySymbol[symbol] = SymbolData(self, symbol) if self.symbolDataBySymbol[symbol].HasNewMax: self.MarketOrder(symbol, 100) for security in changes.RemovedSecurities: symbol = security.Symbol self.Liquidate(symbol) self.symbolDataBySymbol.pop(symbol) class SymbolData: def __init__(self, algorithm, symbol): self.symbol = symbol self.max = algorithm.MAX(symbol, 252, Resolution.Daily, Field.High) self.maxWindow = RollingWindow[IndicatorDataPoint](2) # Warm up history = algorithm.History(symbol, 253, Resolution.Daily) for bar in history.itertuples(): self.max.Update(bar.Index[1], bar.high) self.max.Updated += lambda sender, bar: self.maxWindow.Add(bar) @property def HasNewMax(self): if self.maxWindow.IsReady: return self.maxWindow[0] > self.maxWindow[1] else: return False