bug

My code worked in the environment of Lab, but it didn’t work when I ran it in the notebook.


Generating weights for payout_1michael95201001


---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-4103462bd357> in <module>
4 port = alphien.portfolio.Portfolio(tkr)
5 port.payout(payout_1,prices,stocks,22)
----> 6 port.evaluate()
7 port.backtest(zoom=‘2009::2016’)

/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)
437 if self.features is None:
438 self.features = DataFeatures(self.assets, fields=‘bb_live’, startDate=startDate, endDate=endDate)
–> 439 self.features.load(startDate=startDate, endDate=endDate, zoom=zoom, lastN = computationDataPoints)
440 if loadFromFeatures==‘positional’:
441 self.payoutParams[0][i][0] = self.features.pxs

/mnt/public/IT/Libs/Python/alphien/data/dataFeatures.py in load(self, fields, startDate, endDate, zoom, period, lastN, cleaningFun, cleaningFunArgs, cleaningMethod)
304 start= self.startDate if isinstance(self.startDate, str) or self.startDate is None else self.startDate.strftime(’%Y-%m-%d’),
305 end=self.endDate if isinstance(self.endDate, str) or self.endDate is None else self.endDate.strftime(’%Y-%m-%d’),
–> 306 lastN=lastN, period=period)
307 #ensure index is datetime
308 #self.pxs.index = pd.to_datetime(self.pxs.index)

/mnt/public/IT/Libs/Python/alphien/data/dataFeatures.py in pxs(self, priceDf)
222 def pxs(self, priceDf):
223 if isinstance(priceDf, pd.Series): priceDf = priceDf.to_frame()
–> 224 if not isinstance(priceDf, pd.DataFrame): raise TypeError(f’Prices have to be a data frame. {type(priceDf)} was passed.’)
225 self._pxs = priceDf
226

TypeError: Prices have to be a data frame. <class ‘NoneType’> was passed.


Hi Michael,

Can you restart your notebook kernel please and re-run it. Looks like it could have been a temporary hiccup while fetching the data.

Let me know if it worked.

Thanks