4

I've tested ADF with stattools, my code is

import statsmodels.tsa.stattools as ts  
from datetime import datetime

import zipline  
from zipline import TradingAlgorithm  
from zipline.api import order_target, record, symbol, history, add_history

data = get_pricing(['AAPL'],start_date='2015-01-13',end_date = '2015-02-13',frequency='daily')  
result = ts.adfuller(data.price.values,1)

However, I've got the following error,

ValueError                                Traceback (most recent call last)  
<ipython-input-45-44774ff05797> in <module>()  
      7  
      8 data = get_pricing(['AAPL'],start_date='2015-01-13',end_date = '2015-02-13',frequency='daily')  
----> 9 result = ts.adfuller(data.price.values,1)

/usr/local/lib/python2.7/dist-packages/statsmodels/tsa/stattools.pyc in adfuller(x, maxlag, regression, autolag, store, regresults)
    209  
    210     xdiff = np.diff(x)  
--> 211     xdall = lagmat(xdiff[:, None], maxlag, trim='both', original='in')  
    212     nobs = xdall.shape[0]  # pylint: disable=E1103  
    213 

/usr/local/lib/python2.7/dist-packages/statsmodels/tsa/tsatools.pyc in lagmat(x, maxlag, trim, original)
    322     if x.ndim == 1:  
    323         x = x[:,None]  
--> 324     nobs, nvar = x.shape  
    325     if original in ['ex','sep']:  
    326         dropidx = nvar

ValueError: too many values to unpack

I couldn't see the problem. I think the parameters of adfullter is ok.

Anyone could help?? Thanks a lot...

Lucas
  • 51
  • 7
  • What's the shape of your `data.price.values`? From the traceback it looks like it's strictly larger than 2 dimensions, while the code can handle only 1-D or 2-D. (My guess is that this should be reported to the statsmodels issue tracker to raise a more informative error message if it's a shape mismatch.) – Josef Jul 09 '15 at 21:43
  • Thanks for your reply, it's one dimension. For example, [[ 110.225]..... [ 127.08 ]]. I've already checked the dimension. – Lucas Jul 09 '15 at 21:49
  • 5
    `[[ 110.225]..... [ 127.08 ]]` is 2-dim AFAICS, shape (nobs, 1). To check, try to ravel: `result = ts.adfuller(data.price.values.ravel(),1)` – Josef Jul 09 '15 at 22:02
  • Thanks a lot! It works – Lucas Jul 10 '15 at 07:35

0 Answers0