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 -5.466 Tracking Error 0.099 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class LogicalFluorescentOrangeDinosaur(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 7) self.SetEndDate(2019, 4, 1) self.SetCash(100000) self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.CoarseSelectionFunction) self.indicators = { } def CoarseSelectionFunction(self, universe): selected = [] universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True) universe = [c for c in universe if c.Price > 10][:100] for coarse in universe: symbol = coarse.Symbol if symbol not in self.indicators: # 1. Call history to get an array of 200 days of history data history = self.History(symbol, 200, Resolution.Daily) #2. Adjust SelectionData to pass in the history result self.indicators[symbol] = SelectionData(history) self.indicators[symbol].update(self.Time, coarse.AdjustedPrice) if self.indicators[symbol].is_ready() and \ self.indicators[symbol].bollinger.UpperBand.Current.Value < self.indicators[symbol].keltner.UpperBand.Current.Value and \ self.indicators[symbol].bollinger.LowerBand.Current.Value > self.indicators[symbol].keltner.LowerBand.Current.Value: selected.append(symbol) return selected[:10] class SelectionData(): #3. Update the constructor to accept a history array def __init__(self, history): self.bollinger = BollingerBands(20, 2, MovingAverageType.Simple) self.keltner = KeltnerChannels(20, 1.5, MovingAverageType.Simple) #4. Loop over the history data and update the indicatorsc for bar in history.itertuples(): tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high, bar.low, bar.close, bar.volume, timedelta(1)) self.bollinger.Update(bar.Index[1], bar.close) self.keltner.Update(tradeBar) # @property #def BollingerUpper(self): # return float(self.bollinger.UpperBand.Current.Value) #@property #def BollingerLower(self): # return float(self.bollinger.LowerBand.Current.Value) #@property #def KeltnerUpper(self): # return float(self.keltner.UpperBand.Current.Value) #@property #def KeltnerLower(self): # return float(self.keltner.LowerBand.Current.Value) def is_ready(self): return self.bollinger.IsReady and self.keltner.IsReady def update(self, time, value): return self.bollinger.Update(time, value)