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.497 Tracking Error 0.189 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
# from AlgorithmImports import * class CalmApricotGalago(QCAlgorithm): def Initialize(self): # Set the start and end dates for the backtest self.SetStartDate(2020, 1, 1) self.SetEndDate(2023, 12, 31) # Add the AMD stock to the algorithm self.AddEquity("AMD", Resolution.Minute) # Get the parameter value from the algorithm settings self.parameter_value = self.GetParameter("parameter-name") def OnData(self, data): if not data.ContainsKey("AMD"): return close = data["AMD"].Close class CalmApricotGalago(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2023, 12, 31) self.AddEquity("AMD", Resolution.Minute) self.parameter_value = self.GetParameter("parameter-name") def OnData(self, data): if not data.ContainsKey("AMD"): return close = data["AMD"].Close self.check_entry_points(close) def check_entry_points(self, price): bullish_signals = self.has_bullish_signals(price) bearish_signals = self.has_bearish_signals(price) if bullish_signals and price >= self.support1: self.open_long_position("AMD", 0.1) self.set_stop_loss(price - 0.035) if bearish_signals and price <= self.resistance1: self.open_short_position("AMD", 0.1) self.set_stop_loss(price + 0.035) def has_bullish_signals(self, price): # Implement your logic here pass def has_bearish_signals(self, price): # Implement your logic here pass def open_long_position(self, stock, quantity=0.1): order = Order(stock, quantity, OrderSide.Buy) self.SubmitOrder(order) def open_short_position(self, stock, quantity=0.1): order = Order(stock, quantity, OrderSide.Sell) self.SubmitOrder(order) def set_stop_loss(self, stock, price): order = StopLossOrder(stock, price, OrderSide.SellShort if price < self.Portfolio.Cash else OrderSide.Buy) self.SubmitOrder(order) # Check for entry points based on price and market conditions self.check_entry_points(close) def check_entry_points(self, price): # Implement logic to determine bullish signals bullish_signals = self.has_bullish_signals(price) # Implement logic to determine bearish signals bearish_signals = self.has_bearish_signals(price) if bullish_signals and price >= self.support1: self.open_long_position("AMD", 0.1) self.set_stop_loss(price - 0.035) if bearish_signals and price <= self.resistance1: self.open_short_position("AMD", 0.1) self.set_stop_loss(price + 0.035) def has_bullish_signals(self, price): # Implement your logic here if price > self.sma.Current.Value: return True else: return False def has_bearish_signals(self, price): # Implement your logic here if price < self.sma.Current.Value: return True else: return False def has_bullish_signals(self, price): # Implement logic to determine bullish signals based on price pass def has_bearish_signals(self, price): # Implement logic to determine bearish signals based on price pass def open_long_position(self, stock, quantity=0.1): self.Log("Opening long position in {0}".format(stock)) order = Order(stock, quantity, OrderSide.Buy) self.SubmitOrder(order) def open_short_position(self, stock, quantity=0.1): self.Log("Opening short position in {0}".format(stock)) order = Order(stock, quantity, OrderSide.Sell) self.SubmitOrder(order) def set_stop_loss(self, stock, price): self.Log("Setting stop loss for {0} at {1}".format(stock, price)) order = StopLossOrder(stock, price, OrderSide.SellShort if price < self.Portfolio.Cash else OrderSide.Buy) self.SubmitOrder(order)