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.396 Tracking Error 0.117 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021,6,26) self.SetCash(5000000) self.Data_Symbol = {} tickers = ["SPY", #10 stocks per row "AAPL", "MSFT", "GOOGL", "AMZN", "TSLA", "FB", "NVDA", "TSM", "V", "UNH", "JPM", "JNJ", "HD", "PG", "WMT", "BAC", "MA", "ASML", "PFE", "BABA", "DIS", "AVGO", "NFLX", "ADBE", "CSCO", "NTES", "NKE", "LLY", ] self.SetWarmUp(10, Resolution.Daily) for stock in tickers: symbol = self.AddEquity(stock, Resolution.Minute).Symbol self.Data_Symbol[symbol] = SymbolData(self, symbol) self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.Every(timedelta(minutes=1)), self.EveryDayAfterMarketOpen) def EveryDayAfterMarketOpen(self): if self.IsWarmingUp: return for symbol, symbol_data in self.Data_Symbol.items(): if not symbol_data.rsi_win.IsReady: return holdings = self.Portfolio[symbol] invested = holdings.Invested nowprice = holdings.Price aveprice = holdings.AveragePrice quantity = holdings.Quantity bpower = self.Portfolio.Cash OpenOrders = self.Transactions.GetOpenOrders(symbol) today_rsi = symbol_data.rsi_win[0] yesterday_rsi = symbol_data.rsi_win[1] day_before_yesterday_rsi = symbol_data.rsi_win[2] if OpenOrders: return # This part works if not invested: if today_rsi > yesterday_rsi: if self.LiveMode: self.Log(f'{symbol} bought on {self.Time}') class SymbolData: def __init__ (self,algo,symbol): self.algorithm = algo self.symbol = symbol self.rsi = algo.RSI(symbol, 14, MovingAverageType.Simple, Resolution.Daily) self.rsi_win = RollingWindow[float](3) self.rsi.Updated += lambda sender,updated: self.rsi_win.Add(self.rsi.Current.Value)