From 844a25766debf4287b92e37a7151cdbc8dd14422 Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 10:30:01 -0700 Subject: [PATCH 1/7] Add manual indicator alternative for index-options-static --- project-templates/python/index-options-static/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index 21b75849ce..5b172107dd 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -18,6 +18,11 @@ def initialize(self) -> None: # The EMA/price cross will determine we trade ATM contracts index = self.add_index("SPX") self.ema(index, 60).updated += self._trade_at_the_money_contract + # Alternatively, use a manual indicator. + # self._ema = ExponentialMovingAverage(60) + # self.warm_up_indicator(index.symbol, self._ema) + # self.register_indicator(index.symbol, self._ema) + # self._ema.updated += self._trade_at_the_money_contract self._option_chain_symbol = Symbol.create_canonical_option(index, "SPXW", Market.USA, "?SPXW") From d1a5d503c3001eedebf8566c596af80dee7832d9 Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 10:37:26 -0700 Subject: [PATCH 2/7] Use securities in manual indicator comments --- project-templates/python/index-options-static/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index 5b172107dd..33a96a3355 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -20,8 +20,8 @@ def initialize(self) -> None: self.ema(index, 60).updated += self._trade_at_the_money_contract # Alternatively, use a manual indicator. # self._ema = ExponentialMovingAverage(60) - # self.warm_up_indicator(index.symbol, self._ema) - # self.register_indicator(index.symbol, self._ema) + # self.warm_up_indicator(index, self._ema) + # self.register_indicator(index, self._ema) # self._ema.updated += self._trade_at_the_money_contract self._option_chain_symbol = Symbol.create_canonical_option(index, "SPXW", Market.USA, "?SPXW") From 46a6d8ca8f94af7950539054d4cabfea0cbd1ed0 Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 10:49:31 -0700 Subject: [PATCH 3/7] Add C# manual indicator alternative --- project-templates/csharp/index-options-static/Main.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project-templates/csharp/index-options-static/Main.cs b/project-templates/csharp/index-options-static/Main.cs index 6661a1d99e..a3f208c44d 100644 --- a/project-templates/csharp/index-options-static/Main.cs +++ b/project-templates/csharp/index-options-static/Main.cs @@ -81,6 +81,11 @@ public override void Initialize() // The EMA/price cross will determine we trade ATM contracts var index = AddIndex("SPX"); EMA(index.Symbol, 60).Updated += TradeAtTheMoneyContract; + // Alternatively, use a manual indicator. + // var ema = new ExponentialMovingAverage(60); + // WarmUpIndicator(index.Symbol, ema); + // RegisterIndicator(index.Symbol, ema); + // ema.Updated += TradeAtTheMoneyContract; _optionChainSymbol = QuantConnect.Symbol.CreateCanonicalOption(index, "SPXW", Market.USA, "?SPXW"); } From 4246d3dae15fe4958627a4330c8291ffb45690dc Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 11:22:14 -0700 Subject: [PATCH 4/7] Clarify manual indicator warm-up comments --- project-templates/csharp/index-options-static/Main.cs | 9 +++++---- project-templates/python/index-options-static/main.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/project-templates/csharp/index-options-static/Main.cs b/project-templates/csharp/index-options-static/Main.cs index a3f208c44d..cb088f9efb 100644 --- a/project-templates/csharp/index-options-static/Main.cs +++ b/project-templates/csharp/index-options-static/Main.cs @@ -72,18 +72,19 @@ public override void Initialize() SetStartDate(2024, 9, 1); SetEndDate(2024, 9, 5); SetCash(500000); + // AutomaticIndicatorWarmUp only supports automatic indicators, not manual indicators. Settings.AutomaticIndicatorWarmUp = true; UniverseSettings.MinimumTimeInUniverse = TimeSpan.Zero; // Warm-up the option contracts as soon as it is added to the algorithm Settings.SeedInitialPrices = true; - // The EMA/price cross will determine we trade ATM contracts + // The EMA/price cross will determine we trade ATM contracts var index = AddIndex("SPX"); EMA(index.Symbol, 60).Updated += TradeAtTheMoneyContract; // Alternatively, use a manual indicator. // var ema = new ExponentialMovingAverage(60); - // WarmUpIndicator(index.Symbol, ema); + // WarmUpIndicator(index.Symbol, ema); // RegisterIndicator(index.Symbol, ema); // ema.Updated += TradeAtTheMoneyContract; @@ -100,7 +101,7 @@ public void TradeAtTheMoneyContract(object sender, IndicatorDataPoint current) if (!ema.IsReady) return; var spot = Securities[current.Symbol].Price; - + if (spot > current && spot > ema[-1]) { var atmCall = GetAtTheMoneyContract(OptionRight.Call, spot); @@ -134,7 +135,7 @@ private Option GetAtTheMoneyContract(OptionRight right, decimal spot) { return null; } - + return AddOptionContract(atm); } } diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index 33a96a3355..094c01ad82 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -9,13 +9,14 @@ def initialize(self) -> None: self.set_start_date(2024, 9, 1) self.set_end_date(2024, 9, 5) self.set_cash(500000) + # automatic_indicator_warm_up only supports automatic indicators, not manual indicators. self.settings.automatic_indicator_warm_up = True self.universe_settings.minimum_time_in_universe = timedelta(0) # Warm-up the option contracts as soon as it is added to the algorithm self.settings.seed_initial_prices = True - # The EMA/price cross will determine we trade ATM contracts + # The EMA/price cross will determine we trade ATM contracts index = self.add_index("SPX") self.ema(index, 60).updated += self._trade_at_the_money_contract # Alternatively, use a manual indicator. @@ -34,7 +35,7 @@ def _trade_at_the_money_contract(self, ema: ExponentialMovingAverage, current: I if not ema.is_ready: return spot = self.securities[current.symbol].price - + if spot > current.value and spot > ema[-1].value: atm_call = self._get_at_the_money_contract(OptionRight.CALL, spot) if atm_call and not atm_call.invested: From 8a2fbbc2b4db5ea849a1c41ecc506c0c9ae0a60f Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 12:30:04 -0700 Subject: [PATCH 5/7] Fix alternative template review issues --- .../csharp/index-options-static/Main.cs | 14 ++++++-------- .../python/index-options-static/main.py | 10 ++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/project-templates/csharp/index-options-static/Main.cs b/project-templates/csharp/index-options-static/Main.cs index cb088f9efb..e59da9ffa4 100644 --- a/project-templates/csharp/index-options-static/Main.cs +++ b/project-templates/csharp/index-options-static/Main.cs @@ -81,12 +81,10 @@ public override void Initialize() // The EMA/price cross will determine we trade ATM contracts var index = AddIndex("SPX"); - EMA(index.Symbol, 60).Updated += TradeAtTheMoneyContract; - // Alternatively, use a manual indicator. - // var ema = new ExponentialMovingAverage(60); - // WarmUpIndicator(index.Symbol, ema); - // RegisterIndicator(index.Symbol, ema); - // ema.Updated += TradeAtTheMoneyContract; + var ema = new ExponentialMovingAverage(60); + WarmUpIndicator(index.Symbol, ema); + RegisterIndicator(index.Symbol, ema); + ema.Updated += TradeAtTheMoneyContract; _optionChainSymbol = QuantConnect.Symbol.CreateCanonicalOption(index, "SPXW", Market.USA, "?SPXW"); } @@ -94,8 +92,8 @@ public override void Initialize() public void TradeAtTheMoneyContract(object sender, IndicatorDataPoint current) { // Pace trades every 10 minutes - var lastTrateTime = _lastTicket?.Time ?? DateTime.MinValue; - if ((UtcTime-lastTrateTime).TotalMinutes < 10) return; + var lastTradeTime = _lastTicket?.Time ?? DateTime.MinValue; + if ((UtcTime-lastTradeTime).TotalMinutes < 10) return; var ema = sender as ExponentialMovingAverage; if (!ema.IsReady) return; diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index 094c01ad82..8d156fa116 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -18,12 +18,10 @@ def initialize(self) -> None: # The EMA/price cross will determine we trade ATM contracts index = self.add_index("SPX") - self.ema(index, 60).updated += self._trade_at_the_money_contract - # Alternatively, use a manual indicator. - # self._ema = ExponentialMovingAverage(60) - # self.warm_up_indicator(index, self._ema) - # self.register_indicator(index, self._ema) - # self._ema.updated += self._trade_at_the_money_contract + self._ema = ExponentialMovingAverage(60) + self.warm_up_indicator(index, self._ema) + self.register_indicator(index, self._ema) + self._ema.updated += self._trade_at_the_money_contract self._option_chain_symbol = Symbol.create_canonical_option(index, "SPXW", Market.USA, "?SPXW") From af3eebe0d671ff0612d5ad423ff1c16c05bc9104 Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 13:38:24 -0700 Subject: [PATCH 6/7] Restore automatic EMA example --- project-templates/csharp/index-options-static/Main.cs | 11 ++++++----- project-templates/python/index-options-static/main.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/project-templates/csharp/index-options-static/Main.cs b/project-templates/csharp/index-options-static/Main.cs index e59da9ffa4..2bd0e237ad 100644 --- a/project-templates/csharp/index-options-static/Main.cs +++ b/project-templates/csharp/index-options-static/Main.cs @@ -72,7 +72,6 @@ public override void Initialize() SetStartDate(2024, 9, 1); SetEndDate(2024, 9, 5); SetCash(500000); - // AutomaticIndicatorWarmUp only supports automatic indicators, not manual indicators. Settings.AutomaticIndicatorWarmUp = true; UniverseSettings.MinimumTimeInUniverse = TimeSpan.Zero; @@ -81,10 +80,12 @@ public override void Initialize() // The EMA/price cross will determine we trade ATM contracts var index = AddIndex("SPX"); - var ema = new ExponentialMovingAverage(60); - WarmUpIndicator(index.Symbol, ema); - RegisterIndicator(index.Symbol, ema); - ema.Updated += TradeAtTheMoneyContract; + EMA(index.Symbol, 60).Updated += TradeAtTheMoneyContract; + // To use a manual EMA instead, replace the automatic indicator above with: + // var ema = new ExponentialMovingAverage(60); + // WarmUpIndicator(index.Symbol, ema); + // RegisterIndicator(index.Symbol, ema); + // ema.Updated += TradeAtTheMoneyContract; _optionChainSymbol = QuantConnect.Symbol.CreateCanonicalOption(index, "SPXW", Market.USA, "?SPXW"); } diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index 8d156fa116..b7ca12cfae 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -9,7 +9,6 @@ def initialize(self) -> None: self.set_start_date(2024, 9, 1) self.set_end_date(2024, 9, 5) self.set_cash(500000) - # automatic_indicator_warm_up only supports automatic indicators, not manual indicators. self.settings.automatic_indicator_warm_up = True self.universe_settings.minimum_time_in_universe = timedelta(0) @@ -18,10 +17,12 @@ def initialize(self) -> None: # The EMA/price cross will determine we trade ATM contracts index = self.add_index("SPX") - self._ema = ExponentialMovingAverage(60) - self.warm_up_indicator(index, self._ema) - self.register_indicator(index, self._ema) - self._ema.updated += self._trade_at_the_money_contract + self.ema(index, 60).updated += self._trade_at_the_money_contract + # To use a manual EMA instead, replace the automatic indicator above with: + # ema = ExponentialMovingAverage(60) + # self.warm_up_indicator(index, ema) + # self.register_indicator(index, ema) + # ema.updated += self._trade_at_the_money_contract self._option_chain_symbol = Symbol.create_canonical_option(index, "SPXW", Market.USA, "?SPXW") From 3f80823253d1c363816450348c90ffb0fb265cbe Mon Sep 17 00:00:00 2001 From: Rudy Osuna Date: Thu, 18 Jun 2026 13:42:16 -0700 Subject: [PATCH 7/7] Keep EMA subscription active --- project-templates/csharp/index-options-static/Main.cs | 4 ++-- project-templates/python/index-options-static/main.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project-templates/csharp/index-options-static/Main.cs b/project-templates/csharp/index-options-static/Main.cs index 2bd0e237ad..9c7817d22b 100644 --- a/project-templates/csharp/index-options-static/Main.cs +++ b/project-templates/csharp/index-options-static/Main.cs @@ -80,12 +80,12 @@ public override void Initialize() // The EMA/price cross will determine we trade ATM contracts var index = AddIndex("SPX"); - EMA(index.Symbol, 60).Updated += TradeAtTheMoneyContract; + var ema = EMA(index.Symbol, 60); // To use a manual EMA instead, replace the automatic indicator above with: // var ema = new ExponentialMovingAverage(60); // WarmUpIndicator(index.Symbol, ema); // RegisterIndicator(index.Symbol, ema); - // ema.Updated += TradeAtTheMoneyContract; + ema.Updated += TradeAtTheMoneyContract; _optionChainSymbol = QuantConnect.Symbol.CreateCanonicalOption(index, "SPXW", Market.USA, "?SPXW"); } diff --git a/project-templates/python/index-options-static/main.py b/project-templates/python/index-options-static/main.py index b7ca12cfae..60d10333ea 100644 --- a/project-templates/python/index-options-static/main.py +++ b/project-templates/python/index-options-static/main.py @@ -17,12 +17,12 @@ def initialize(self) -> None: # The EMA/price cross will determine we trade ATM contracts index = self.add_index("SPX") - self.ema(index, 60).updated += self._trade_at_the_money_contract + ema = self.ema(index, 60) # To use a manual EMA instead, replace the automatic indicator above with: # ema = ExponentialMovingAverage(60) # self.warm_up_indicator(index, ema) # self.register_indicator(index, ema) - # ema.updated += self._trade_at_the_money_contract + ema.updated += self._trade_at_the_money_contract self._option_chain_symbol = Symbol.create_canonical_option(index, "SPXW", Market.USA, "?SPXW")