Hello,
I'm new to QC, and what I trying to achieve is the following:

  1. Once a day, my code being called (after or before market hours)
  2. My code iterates all stocks in the US market, and selects investment candidates based on some criterias
  3. Makes orders if needed, renew existing pending orders if expired.

 

For start, I tried to do the following:
 

class SquareYellowDolphin(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2023, 8, 21)
        self.SetEndDate(2023, 10, 21)
        self.SetCash(100000)
        self.UniverseSettings.Resolution = Resolution.Daily  # Set universe resolution to daily
        self.AddUniverse(self.coarse_selection_function)

    def coarse_selection_function(self, coarse):
        self.Debug(f'Coarse selection called at [{self.Time}]')
        sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
        return [x.Symbol for x in sortedByDollarVolume[:100]]

    def OnData(self, data: Slice):
        self.Debug(f'OnData called at [{self.Time}]')

 

Expectation: ‘coarse_selection_function’ will be called once a day, will select stocks according to criteria. ‘OnData’ will be called once a day, and could review selected stocks and do whatever needed.

Actual: ‘coarse_selection_function’ called once a day (as expected) but ‘OnData’ called every minute.


How to achieve what I need (e.g. make ‘OnData’ called once a day)? Am I in the right direction at all, or it should be done somehow differently? Appreciate any help, thanks.