Submission sometimes runs into error and sometimes works just fine

My team last submission on SP500 competition is "NewSubmissionSP500.ipynb"


I tried running it multiple times (i.e. restart and then run) and sometimes it works fine and sometimes it runs into the following error:

# ---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-5-8d3cd56f6855> in <module>

----> 1 pf.evaluate()

/mnt/public/IT/Libs/Python/alphien/portfolio/portfolio.py in evaluate(self, startDate, endDate, zoom, period, lastN, computationDataPoints, rollEval, alignAndFillDates)

#     394         if rollEval is None:
#     395             self.singleEval(startDate=startDate, endDate=endDate, zoom=zoom, period=period, lastN=lastN, computationDataPoints=computationDataPoints, 

–> 396                  rollEval=False, alignAndFillDates=alignAndFillDates)

#     397         else:
#     398             self.rollEval(startDate=startDate, endDate=endDate, zoom=zoom, period=period, rollingWindow=rollEval, computationDataPoints=computationDataPoints)

/mnt/public/IT/Libs/Python/alphien/portfolio/portfolio.py in singleEval(self, startDate, endDate, zoom, period, lastN, computationDataPoints, rollEval, alignAndFillDates, composeLogic)

#     446             try:
#     447                 if i==0:

–> 448                     weights = payout(*self.payoutParams[0][i],**self.payoutParams[1][i])

#     449                 else:
#     450                     # If i>0, compose weights as defined by composeLogic

<ipython-input-3-9e44cc62edd8> in VolatilityTimedMomentum(features, select, x)

#      25 
#      26     print(inclusion_stacked, momentum_stacked)

—> 27     momentum_incl = pd.merge(inclusion_stacked, momentum_stacked, left_index = True, right_index=True, how=‘left’)

#      28     momentum_incl = momentum_incl[~momentum_incl[‘momentum’].isnull()]
#      29     momentum_incl = momentum_incl.drop(‘inclusion’, axis = 1)

AttributeError: ‘NoneType’ object has no attribute ‘merge’


My best guess is this is some kind of memory error from the notebook becuase when I run it slowly (i.e. run cell by cell) it ussually works fine

Hello - have you tried to run your code on Alphien lab to see if that works ?


Thanks.

I just tried running it again and it seems to work fine now, thanks.