Frank Giardina - Thanks for the link. I've gone through and retried this with success! The difference that solved it for me was usingÂ
self.spy = Symbol.Create('SPY', SecurityType.Equity, Market.USA)Â
rather than the usualÂ
self.spy = self.AddEquity("SPY", Resolution.Minute)
For anyone coming across this post in the future, here is a more complete example of a solution to refer to than the one in the thread linked above:
class MomentumEffAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 1) # Set Start Date
self.SetEndDate(2020, 11, 1) # Set End Date
self.SetCash(100000) # Set Strategy Cash
# Create your symbols here
self.agg = Symbol.Create('AGG', SecurityType.Equity, Market.USA)
self.tlt = Symbol.Create('TLT', SecurityType.Equity, Market.USA)
self.ief = Symbol.Create('IEF', SecurityType.Equity, Market.USA)
self.iei = Symbol.Create('IEI', SecurityType.Equity, Market.USA)
# Add your symbols to a list
self.addedsymbols = [self.agg, self.tlt, self.ief, self.iei]
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
def CoarseSelectionFunction(self, coarse):
self.selected = sorted([x for x in coarse if x.HasFundamentalData and x.Price > 5],
key=lambda x: x.DollarVolume, reverse=True)
self.coarselist = [x.Symbol for x in self.selected[:100]]
for symbol in self.addedsymbols:
self.coarselist.append(symbol)
return self.coarselist
def FineSelectionFunction(self, fine):
fine = [f for f in fine if f.ValuationRatios.PERatio > 0
and f.EarningReports.BasicEPS.TwelveMonths > 0
and f.EarningReports.BasicAverageShares.ThreeMonths > 0
]
self.selectedfine = sorted(fine,
key=lambda f: f.ValuationRatios.PERatio *
f.EarningReports.BasicEPS.TwelveMonths *
f.EarningReports.BasicAverageShares.ThreeMonths,
reverse=True)
self.finesymbols = [x.Symbol for x in self.selectedfine[:50]]
for symbol in self.addedsymbols:
self.finesymbols.append(symbol)
return self.finesymbols
No updates to OnSecurities changed or OnData are necessary. The symbols are there!
*Note* - not sure why the formatting is screwed up, I'll repost it below with the correct indentation.