Dear Sir,
When I run my strategy, all goes well untill running backtest(). Could you please help me in your end?
The error is :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-7fb61b6786f7> in <module>
----> 1 port.backtest()/mnt/public/IT/Libs/Python/alphien/portfolio/portfolio.py in backtest(self, zoom, period, plot, printStats, tc, fc)
560
561 #single stats
–> 562 startDatetime = datetime.datetime.strptime(str(cumulativePnl.first_valid_index().date()), ‘%Y-%m-%d’)
563 endDatetime = datetime.datetime.strptime(str(cumulativePnl.last_valid_index().date()), ‘%Y-%m-%d’)
564 timeDelta = (endDatetime - startDatetime).daysAttributeError: ‘NoneType’ object has no attribute ‘date’
I have read payout noyebook many times and checked my payout indeed took a pandas dataframe (with dates as indices) as first argument and return a pandas data frame (again with dates as indices) of weights.
px.index
Index([‘2016-01-04’, ‘2016-01-05’, ‘2016-01-06’, ‘2016-01-07’, ‘2016-01-08’,
‘2016-01-11’, ‘2016-01-12’, ‘2016-01-13’, ‘2016-01-14’, ‘2016-01-15’,
…
‘2017-12-15’, ‘2017-12-18’, ‘2017-12-19’, ‘2017-12-20’, ‘2017-12-21’,
‘2017-12-22’, ‘2017-12-26’, ‘2017-12-27’, ‘2017-12-28’, ‘2017-12-29’],
dtype=‘object’, name=‘date’, length=503)
res.index
Index([‘2016-01-04’, ‘2016-01-05’, ‘2016-01-06’, ‘2016-01-07’, ‘2016-01-08’,
‘2016-01-11’, ‘2016-01-12’, ‘2016-01-13’, ‘2016-01-14’, ‘2016-01-15’,
…
‘2017-12-15’, ‘2017-12-18’, ‘2017-12-19’, ‘2017-12-20’, ‘2017-12-21’,
‘2017-12-22’, ‘2017-12-26’, ‘2017-12-27’, ‘2017-12-28’, ‘2017-12-29’],
dtype=‘object’, name=‘date’, length=503)
where res is my payoutfuntion