Overall Statistics |
Total Trades 94 Average Win 6.37% Average Loss -5.70% Compounding Annual Return -99.237% Drawdown 61.200% Expectancy -0.189 Net Profit -47.800% Sharpe Ratio -0.598 Probabilistic Sharpe Ratio 13.274% Loss Rate 62% Win Rate 38% Profit-Loss Ratio 1.12 Alpha 0 Beta 0 Annual Standard Deviation 1.524 Annual Variance 2.324 Information Ratio -0.598 Tracking Error 1.524 Treynor Ratio 0 Total Fees $94.00 Estimated Strategy Capacity $0 Lowest Capacity Asset AMZN Y3LLM9TN0Q3Q|AMZN R735QTJ8XC9X |
from AlgorithmImports import * from datetime import datetime as date class MACD(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 9, 1) self.SetCash(500) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.LastTime = None self.entryTicket = None self.macd = dict() self.symbols = [] symbols = ["AAPL","MSFT","GOOGL","AMZN"] for ticker in symbols: symbol = self.AddEquity(ticker, Resolution.Minute).Symbol option = self.AddOption(symbol, Resolution.Minute) self.symbols.append(option.Symbol) option.SetFilter(-100, 100, timedelta(41), timedelta(60)) self.macd[symbol] = self.MACD(ticker, 12, 26, 9, MovingAverageType.Simple, Resolution.Minute) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(15, 45), self.Liquidate) def OnData(self, data): if not all([macd.IsReady for symbol, macd in self.macd.items()]): return if self.Portfolio.Invested: return for symbol, macd in self.macd.items(): if macd.Current.Value < -0.5: for symbol in self.symbols: for kvp in data.OptionChains: if kvp.Key == symbol: chains = kvp.Value self.BuyCall(chains) def BuyCall(self,chains): expiry = sorted(chains,key = lambda x: x.Expiry, reverse=False)[0].Expiry calls = [kvp for kvp in chains if kvp.Expiry == expiry and kvp.Right == OptionRight.Call and kvp.AskPrice > 1] call_contracts = sorted(sorted(calls, key = lambda x: abs(x.Strike - x.UnderlyingLastPrice)),\ key = lambda x: x.AskPrice, reverse=False) if len(call_contracts) == 0: return self.call = call_contracts[0] quantity = math.ceil((0.1 * self.Portfolio.TotalPortfolioValue) / (self.call.AskPrice*100)) self.entry_ticket = self.LimitOrder(self.call.Symbol, quantity, round(self.call.AskPrice,2))