Backtest

and below is the code when I check the px index column:


px.index
DatetimeIndex([‘2007-01-21’, ‘2007-01-28’, ‘2007-02-04’, ‘2007-02-11’,
‘2007-02-18’, ‘2007-02-25’, ‘2007-03-04’, ‘2007-03-11’,
‘2007-03-18’, ‘2007-03-25’,

‘2016-10-30’, ‘2016-11-06’, ‘2016-11-13’, ‘2016-11-20’,
‘2016-11-27’, ‘2016-12-04’, ‘2016-12-11’, ‘2016-12-18’,
‘2016-12-25’, ‘2017-01-01’],
dtype=‘datetime64[ns]’, name=‘date’, length=520, freq=‘W-SUN’)

I can’t seem to find out what’s causing the error…if I add an index column before the date column then there are unexpected column numbers of 5 instead of 4.


Below is the info of px for reference:

px.info()
<class ‘pandas.core.frame.DataFrame’>
DatetimeIndex: 520 entries, 2007-01-21 to 2017-01-01
Freq: W-SUN
Data columns (total 4 columns):

Column Non-Null Count Dtype


0 AAPL.US Equity 520 non-null int64
1 AMZN.US Equity 520 non-null int64
2 GOOG.US Equity 520 non-null int64
3 FB.US Equity 520 non-null int64
dtypes: int64(4)
memory usage: 20.3 KB

Thanks for all the help!

Hello,


Can you please provide us with a minimal reproducible example so that we can have a look at it on our end?

Please feel free to use private chat to Yongcheng if you want to keep your code private.


At Alphien we want to make sure that no preference is given to any team for the competition, we act as an independent, fair and neutral to give equal chance to everyone. We are here to help everyone !


Happy coding, Lionel.



Dear Sir,

    I meet exactly the same problem. When I run backtest, the same problem exists–AttributeError: ‘NoneType’ object has no attribute ‘date’