Suppose we have an algorithm architecture like:

class MyAlgorithm(QCAlgorithm): def Initialize(self): self.SetUniverseSelection(**kwargs) self.SetAlpha(MyAlphaModel()): def OnData(self, data): class MyAlphaModel(AlphaModel): def __init__(self): pass def OnSecuritiesChanged(self, algorithm, changes): pass def Update(self, algorithm, data): insights = [] return insights

The objective is to take the dataframe of security close prices, apply some function MyFunc() to it, and emit a single scalar value for each security as an Insight object. 

def MyFunc(self, data): for security in self.Securities: # do something return # some scalar value for each security
  • Should MyFunc() be called inside MyAlphaModel.Update or OnData?
  • Is self.Securities automatically populated with security objects from the set Universe, or should an empty list be instantiated and securities appended in MyAlphaModel.OnSecuritiesChanged()?