from datetime import datetime,timedelta
class ParticleNadionChamber(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 1, 13) # Set Start Date
self.SetEndDate(datetime.now())
self.SetCash(1000000) # Set Strategy Cash
#Adding the symbols for the portfolio
self.symbolList = ["MSFT","BP","HSE"]
self.allocation = round(1/len(self.symbolList),2)
self.daily = {}
# list of symbol objects
self.SecuritySymbols = []
for name in self.symbolList:
# get symbol object
symbol = self.AddEquity(name, Resolution.Hour, Market.USA).Symbol
# append to list
self.SecuritySymbols.append(symbol)
self.daily[symbol] = RollingWindow[float](2)
self.SetWarmup(200)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
for symbol in self.SecuritySymbols:
if self.ActiveSecurities[symbol].HasData and data.ContainsKey(symbol):
#data.ContainsKey("EURUSD")
#self.Debug("{}".format(symbol))
# get OHLC values to use later
# o = data.Bars[symbol].Open
# h = data.Bars[symbol].High
# l = data.Bars[symbol].Low
c = data.Bars[symbol].Close
# update our rolling window
self.daily[symbol].Add(c)
# check if rolling window is full
if not (self.daily[symbol].IsReady): return
prev_hour_price = self.daily[symbol][1]
current_bar_close = self.daily[symbol][0]
else: pass