Hi

So I'm looping through some pre-selected pairs (70,000 of them) every day however I'm noticing that in fact that each day the loop is only doing around 3900 and then ending and moving to the next day without any error being thrown, it is also of note that in the trading logic there are no break points so there is no obvious reason the loop is terminating. Could it be an unraised error the ide is sweeping under the rug and causing this loop to simply break yet simply go unmentioned?

Here is some stripped down example code, note that indeed there is a 40,000th entry to my pairs and it does print this fine

 

 


class PairsTradingAlgorithm(QCAlgorithm):


def Initialize(self):

#some parmerter stuff has been removed




self.pairs_list = ### all my pairs






self.SetCash(100000) # Set Strategy Cash
self.AddAlpha(PearsonCorrelationPairsTradingAlphaModel(252, Resolution.Daily))

self.SetExecution(ImmediateExecutionModel())
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())

symbols = [ Symbol.Create("NASDAQ", SecurityType.Equity, Market.USA) ]
self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))
#self.SetUniverseSelection( MaanualUniverseSelectionModel(symbols) )

self.SetStartDate(2018,1,1)
self.SetEndDate(2019,6,30)
self.numdays = 60# set the length of training period




tickers = list(set(tickers))
self.symbols = []

self.tick_2_sym_dict = dict()
for i in tickers:
self.symbols.append(self.AddEquity(i,Resolution.Daily).Symbol)


self.lastSlice = None

self.Debug('so it begins!!!!!!!!!!!!!')


for symbol in self.symbols:
self.tick_2_sym_dict[symbol.Value]= x

self.day_run = self.daily_run
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(13, 0), Action( self.day_run))

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'''

self.lastSlice = data


def daily_run(self):
remove_pairs = []

#fucked-up data call back
data = self.lastSlice

if data != None:


self.Debug('New Day')
self.Debug(str(self.Time))
run = 0
count = 0



for pair in self.pairs_list:
run += 1
count += 1

self.Debug(self.pairs_list[40000])
if count == 100:
self.Debug(str(run) + ' of ' + str(len(self.pairs_list)))
count = 0




if not (data.ContainsKey(pair[0]) and data.ContainsKey(pair[1])): return


### need to check this is the last 60 days
price_x = self.History([pair[0]], 60)['close'].values



price_y = self.History([pair[1]], 60)['close'].values



if len(price_x) < 60: return

#######After this is trading logic which importantly doesn't contain any break points etc that
could obviously explain why it would cut out around 3900