5

Just starting Computational Investing by Tucker Balch. I'm using virtualbox and installed Ubuntu. After installing QSTK, I ran python Validation.py (Step 7). I keep getting an:

AttributeError: 'module' object has no attribute 'TimeSeries'

There are many similar questions so I believe problem is the use of the same name as the file somewhere in the code. I was wondering if anyone had a solution specific to this class and QSTK.

The full error is:

Traceback (most recent call last):
 File "Validation.py", line 122 in <module>
  import QSTK.qstkutil.tsutil as tsu
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8 py2.7.egg/QSTK/qstkutil/tsutil.py", line 19, in <module>
  from QSTK.qstkutil import qsdateutil
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py", line 38, in <module>
  GTS_DATES = _cache_dates()
 File "usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py", line 36, in _cache_dates
  return pd.TimeSeries(index=dates, data=dates) 
AttributeError: 'module' object has no attribute 'TimeSeries' 
Wondercricket
  • 7,651
  • 2
  • 39
  • 58
forrest pump
  • 51
  • 1
  • 3
  • 3
    `pd` is probably a reference to `pandas`, but `pandas` doesn't have any `TimeSeries` as far as I can tell. i think that should be just `Series`. Try doing: `import pandas as pd; pd.TimeSeries = pd.Series` and see if that gets you anywhere.... – Corley Brigman Jul 10 '17 at 14:18
  • Huge help. Thank you Corley! – forrest pump Jul 21 '17 at 17:05

3 Answers3

5

I encountered this issue too. This caused by the pandas lib. You can get into the path(my file path is /Library/Python/2.7/site-packages/QSTK/qstkutil) where the qstkutil.py of QSTK located. Then change all the 'TimeSeries' of this file as 'Series'.

You can also get some insights from here(https://github.com/QuantSoftware/QuantSoftwareToolkit/issues/73)

Kate
  • 71
  • 1
  • 5
3

Corley is spot on. You can solve the problem by changing 2 occurrences of "TimeSeries" to "Series" in /usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/qsdateutil.py. "TimeSeries" also appears once in /usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkutil/tsutil.py but I haven't encountered an error yet due to it.

D Scott
  • 31
  • 1
2

Changing TimeSeries to Series corrects the issue for me.

Seems that

import pandas as pd; 
pd.TimeSeries = pd.Series        

should work, but did not for me.

Ankur Aggarwal
  • 2,210
  • 2
  • 34
  • 39
Dale
  • 76
  • 3