Overall Statistics |
Total Trades 2 Average Win 0.21% Average Loss 0% Compounding Annual Return 0.041% Drawdown 0.000% Expectancy 0 Net Profit 0.207% Sharpe Ratio 0.423 Probabilistic Sharpe Ratio 0.027% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0.001 Annual Variance 0 Information Ratio -0.983 Tracking Error 0.186 Treynor Ratio 7.198 Total Fees $8.63 Estimated Strategy Capacity $7900000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class PriceActionTQQQ(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 1, 1) self.SetCash(100000) self.TQQQ = self.AddEquity("QQQ", Resolution.Minute).Symbol self.SetBenchmark("QQQ") self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) self.SetExecution(ImmediateExecutionModel()) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) symbol = [Symbol.Create(self.TQQQ, SecurityType.Equity, Market.USA)] self.AddUniverseSelection(ManualUniverseSelectionModel(symbol)) self.AddAlpha(PriceActionTQQQAlphaModel(self, self.TQQQ)) self.SetRiskManagement(MaximumDrawdownPercentPortfolio(0.045)) self.Schedule.On(self.DateRules.EveryDay(self.TQQQ), self.TimeRules.At(23, 59), self.tradeLockReset) def tradeLockReset(self): self.tradeLock = False class PriceActionTQQQAlphaModel(AlphaModel): tradeLock = False def __init__(self, algorithm, tkr): self.period = timedelta(days=1) self.symbol = tkr self.symbolData = SymbolData(algorithm) def Update(self, algorithm, data): insights = [] HO = 0.0 OL = 0.0 if self.symbolData.Updated: Open = self.symbolData.open High = self.symbolData.high Low = self.symbolData.low Close = self.symbolData.close HO = High - Open OL = Open - Low HC = High - Close CL = Close - Low if Close > Open: if HO > OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None)) self.tradeLock = True if Close < Open: if HO < OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None)) self.tradeLock = True if HO > OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None)) self.tradeLock = True if HO == OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None)) self.tradeLock = True if Close == Open: if HO < OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None)) self.tradeLock = True if HO > OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None)) self.tradeLock = True if HO == OL and self.tradeLock == False: insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Flat, 1, None)) self.tradeLock = True self.symbolData.Updated = False return insights def OnSecuritiesChanged(self, algorithm, changes): self.changes = changes class SymbolData: def __init__(self, algorithm): algorithm.Consolidate("QQQ", Resolution.Daily, self.DailyBarHandler) self.open = 0 self.close = 0 self.high = 0 self.low = 0 self.Updated = False def DailyBarHandler(self, consolidated): self.open = consolidated.Open self.close = consolidated.Close self.high = consolidated.High self.low = consolidated.Low self.Updated = True