class VerticalModulatedCoil(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 2, 15) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.SetUniverseSelection(ManualUniverseSelectionModel([Symbol.Create(symbol, SecurityType.Equity, Market.USA) for symbol in ["SPY", "TLT"]]))
self.SetAlpha(MyAlpha())
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
self.SetExecution(ImmediateExecutionModel())
class MyAlpha(AlphaModel):
def __init__(self):
self.day = 0
def Update(self, algorithm, data):
insights = []
if self.day == algorithm.Time.day:
return insights
self.day = algorithm.Time.day
marketClose = None
for symbol in data.Keys:
if marketClose is None:
marketClose = algorithm.Securities[symbol].Exchange.Hours.GetNextMarketClose(algorithm.Time, False);
insights.append(Insight.Price(symbol, marketClose-timedelta(minutes=1), InsightDirection.Up))
return insights