Hi all,

If I run my code, I only get response/orders for the first day.

I fail in running the code every day and get errors if I try something with: self.Schedule.On(self.DateRules.EveryDay()

Any idea how I can return my code to start every day? I only want to do 1 trade per day.

from AlgorithmImports import *

class BreakoutCallBuy(QCAlgorithm):
    
    openingBar = None

    def Initialize(self):
        self.SetStartDate(2022, 7, 1)
        self.SetEndDate(2022, 7, 17)
        self.SetCash(1000)
        self.LastTime = None
        self.SetBenchmark("SPY")

        equitySPY= self.AddEquity("SPY", Resolution.Minute)
        equitySPY.SetDataNormalizationMode(DataNormalizationMode.Raw)

        self.equitySPY = equitySPY.Symbol
        self.Consolidate("SPY", timedelta(minutes=30), self.OnDataConsolidated)

        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9, 30),self.SetFilter)
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(15, 15), self.Liquidate)

    def SetFilter(self):
        optionSPY = self.AddOption("SPY", Resolution.Minute)
        optionSPY.SetFilter(10, 20, timedelta(14), timedelta(21))

    def OnDataConsolidated(self, bar):
        if bar.Time.hour == 9 and bar.Time.minute == 30:
            self.openingBar = bar

    def OnData(self, data):
        if self.openingBar is None:
            return

        # Maximaal één trade per dag
        if self.LastTime == self.Time.day:
            return
        
        # Trade openen als er breakout is: prijs is hoger dan hoogste prijs in eerste half uur
        if data["SPY"].Close > self.openingBar.High:
            for i in data.OptionChains:
                chains = i.Value
                self.BuyCall(chains)
                self.LastTime = self.Time.day

    # Bepalen welke contracten er worden gekocht            
    def BuyCall(self,chains):
        expiry = sorted(chains,key = lambda x: x.Expiry, reverse=True)[0].Expiry
        calls = [i for i in chains if i.Expiry == expiry and i.Right == OptionRight.Call]
        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]
        
        # Aantal contracten
        quantity = int(300 / (self.call.AskPrice*100))
        self.Buy(self.call.Symbol, quantity)

        self.LimitOrder(self.call.Symbol, -quantity, round((self.call.AskPrice*1.25),2))
        self.StopMarketOrder(self.call.Symbol, -quantity, round((self.call.AskPrice*0.80),2))
        
    # Orders in logboek
    def OnOrderEvent(self, orderEvent):
        self.Log(str(orderEvent))