I’d like to access history of symbols in my Alpha Model.
I know I can call algorithm.history() in my Alpha Model …
But I realized already call algorithm.history() in my Universe Selection
historySlices = algorithm.History(initialFilter, MAX_BARS_BACK, Resolution.Daily)
So I decided to create a dict property of the QCAlgorithm called histories that I can use to save the gotten history, so I don't have to call algorithm.history() again.
class RedGhost(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 1, 12)
self.SetEndDate(2021, 1, 15)
self.SetCash(100000)
self.AddUniverseSelection(UniverseModule())
self.UniverseSettings.Resolution = Resolution.Daily
self.SetAlpha(RGAlphaModel())
self.histories = {}
I try to save the history of each into this dictionary in my Universe Selection Model like …
algorithm.histories[symbol] = history
But I get the error
Runtime Error: AttributeError : 'QCAlgorithm' object has no attribute 'histories'
I’ve clearly attached a dictionary called histories to the self of QCAlgorithm
I don’t what I am doing wrong here. Any ideas welcome.