mementum / bta-lib

Technical Analysis library in pandas for backtesting algotrading and quantitative analysis
MIT License
454 stars 106 forks source link

AttributeError: module 'btalib' has no attribute 'sma' #1

Closed HomunculusK closed 4 years ago

HomunculusK commented 4 years ago
import btalib
import pandas as pd

df = pd.read_csv('2006-day-001.txt', parse_dates=True, index_col='Date')
sma = btalib.sma(df)

gives AttributeError: module 'btalib' has no attribute 'sma'

mementum commented 4 years ago

See a fresh install (where hello-sma.py contains the aforementioned code)

$ pipenv install
Creating a virtualenv for this project▒
Using base prefix ...
New python executable in ...
Installing setuptools, pip, wheel...done.

Virtualenv location: ...
Creating a Pipfile for this project▒
Pipfile.lock not found, creating▒
Locking [dev-packages] dependencies▒
Locking [packages] dependencies▒
Updated Pipfile.lock (c23e27)!
Installing dependencies from Pipfile.lock (c23e27)▒
To activate this project's virtualenv, run the following:

$ pipenv.exe shell

$ pip install bta-lib
Collecting bta-lib
  Using cached bta_lib-0.9.1-py2.py3-none-any.whl (37 kB)
Requirement already satisfied: pandas in \01-docs\01-home\.virtualenvs\btalib-test-qvfqerkr\lib\site-packages (from bta-lib) (1.0.0)
Requirement already satisfied: python-dateutil>=2.6.1 in \01-docs\01-home\.virtualenvs\btalib-test-qvfqerkr\lib\site-packages (from pandas->bta-lib) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in \01-docs\01-home\.virtualenvs\btalib-test-qvfqerkr\lib\site-packages (from pandas->bta-lib) (2019.3)
Requirement already satisfied: numpy>=1.13.3 in \01-docs\01-home\.virtualenvs\btalib-test-qvfqerkr\lib\site-packages (from pandas->bta-lib) (1.18.1)
Requirement already satisfied: six>=1.5 in \01-docs\01-home\.virtualenvs\btalib-test-qvfqerkr\lib\site-packages (from python-dateutil>=2.6.1->pandas->bta-lib) (1.14.0)
Installing collected packages: bta-lib
Successfully installed bta-lib-0.9.1

$ ./hello-sma.py
                    sma
Date
2006-01-02          NaN
2006-01-03          NaN
2006-01-04          NaN
2006-01-05          NaN
2006-01-06          NaN
...                 ...
2006-12-21  2029.800333
2006-12-22  2029.961333
2006-12-27  2030.773333
2006-12-28  2031.545667
2006-12-29  2031.730667

[255 rows x 1 columns]