Overall Statistics |
Total Orders 101 Average Win 3.31% Average Loss -1.42% Compounding Annual Return 174.172% Drawdown 14.400% Expectancy 0.528 Start Equity 100000 End Equity 128811.81 Net Profit 28.812% Sharpe Ratio 3.09 Sortino Ratio 4.811 Probabilistic Sharpe Ratio 79.596% Loss Rate 54% Win Rate 46% Profit-Loss Ratio 2.33 Alpha 0.744 Beta 1.308 Annual Standard Deviation 0.35 Annual Variance 0.123 Information Ratio 2.488 Tracking Error 0.331 Treynor Ratio 0.827 Total Fees $192.50 Estimated Strategy Capacity $11000000.00 Lowest Capacity Asset NFLX SEWJWLJNHZDX Portfolio Turnover 74.52% |
from AlgorithmImports import * class Magnificent7IntradayStrategy(QCAlgorithm): def initialize(self): self.set_start_date(2024, 1, 1) self.set_end_date(2024, 4, 1) self.set_cash(100000) # Define the MEGA-CAP stocks self.symbols = [self.add_equity(ticker, Resolution.MINUTE).symbol for ticker in ["TSLA", "AMZN", "NFLX", "AAPL", "NVDA", "GOOGL", "MSFT", "META"]] # Define indicators self.rsi_indicators = {symbol: self.rsi(symbol, 14, MovingAverageType.WILDERS, Resolution.MINUTE) for symbol in self.symbols} self.sma_indicators = {symbol: self.sma(symbol, 200, Resolution.MINUTE) for symbol in self.symbols} # Schedule trading hours self.schedule.on(self.date_rules.every_day(), self.time_rules.every(timedelta(minutes=15)), self.trade) # Risk management self.set_risk_management(MaximumDrawdownPercentPerSecurity(0.015)) # Track last trade date for each symbol self.last_trade_date = {symbol: None for symbol in self.symbols} def trade(self): current_time = self.Time if current_time.weekday() >= 5 or not (current_time.hour == 9 and current_time.minute >= 45): return for symbol in self.symbols: if not self.rsi_indicators[symbol].is_ready or not self.sma_indicators[symbol].is_ready: continue price = self.securities[symbol].price rsi_value = self.rsi_indicators[symbol].current.value sma_value = self.sma_indicators[symbol].current.value # Check if a trade has already been made today if self.last_trade_date[symbol] == current_time.date(): continue # Entry condition if rsi_value < 30 and price < sma_value: self.set_holdings(symbol, 1) self.last_trade_date[symbol] = current_time.date() # Exit conditions if self.portfolio[symbol].invested: previous_day_high = self.history(symbol, 1, Resolution.Daily)["high"].iloc[0] if price >= previous_day_high or rsi_value > 80: self.liquidate(symbol) self.last_trade_date[symbol] = current_time.date() # Update trade date on exit