Address review
- Increase time lenght of SmartInsider benchmarks. Adding history requests
This commit is contained in:
@@ -25,23 +25,34 @@ class SmartInsiderEventBenchmarkAlgorithm(QCAlgorithm):
|
||||
|
||||
def Initialize(self):
|
||||
# Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
self.SetStartDate(2005, 1, 1)
|
||||
self.SetStartDate(2010, 1, 1)
|
||||
self.SetEndDate(2019, 1, 1)
|
||||
|
||||
tickers = {"AAPL", "AMZN", "MSFT", "IBM", "FB", "QQQ", "IWM", "BAC", "BNO", "AIG", "UW", "WM" }
|
||||
self.securities = []
|
||||
self.customSymbols = []
|
||||
for ticker in tickers:
|
||||
security = self.AddEquity(ticker, Resolution.Daily)
|
||||
security = self.AddEquity(ticker, Resolution.Hour)
|
||||
self.securities.append(security)
|
||||
self.AddData(SmartInsiderIntention, security.Symbol, Resolution.Daily)
|
||||
self.AddData(SmartInsiderTransaction, security.Symbol, Resolution.Daily)
|
||||
|
||||
intetion = self.AddData(SmartInsiderIntention, security.Symbol, Resolution.Daily)
|
||||
transaction = self.AddData(SmartInsiderTransaction, security.Symbol, Resolution.Daily)
|
||||
self.customSymbols.append(intetion.Symbol)
|
||||
self.customSymbols.append(transaction.Symbol)
|
||||
|
||||
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(16, 0), self.DailyRebalance)
|
||||
|
||||
def OnData(self, slice):
|
||||
intentions = slice.Get(SmartInsiderIntention)
|
||||
transactions = slice.Get(SmartInsiderTransaction)
|
||||
|
||||
def DailyRebalance(self):
|
||||
history = self.History(self.customSymbols, timedelta(5))
|
||||
historySymbolCount = len(history.index)
|
||||
|
||||
for security in self.securities:
|
||||
intention = security.Data.Get(SmartInsiderIntention)
|
||||
transaction = security.Data.Get(SmartInsiderTransaction)
|
||||
|
||||
if not security.HoldStock and intention != None and transaction != None and intentions.Count == transactions.Count:
|
||||
self.SetHoldings(security.Symbol, 1 / len(self.securities))
|
||||
if not security.HoldStock and intention != None and transaction != None:
|
||||
self.SetHoldings(security.Symbol, 1 / len(self.securities))
|
||||
Reference in New Issue
Block a user