Permalink
Browse files

Update to fix bollinger bands

  • Loading branch information...
shads2 committed May 16, 2018
1 parent b71576a commit da22472815ad7528fa40828e394aae4c0abee949
View
@@ -13,8 +13,10 @@ RUN cd /tmp && \
ADD app/ /app
WORKDIR /app
# numpy must be installed first for python TA-lib
RUN pip install numpy==1.14.0
RUN pip install -r requirements.txt
# Pip doesn't install requirements sequentially.
# To ensure pre-reqs are installed in the correct
# order they have been split into two files
RUN pip install -r requirements-step-1.txt
RUN pip install -r requirements-step-2.txt
CMD ["/usr/local/bin/python","app.py"]
@@ -3,7 +3,10 @@
import math
from talib import abstract
import tulipy
import numpy
import pandas
#from talib import abstract
from analyzers.utils import IndicatorUtils
@@ -22,7 +25,27 @@ def analyze(self, historical_data, period_count=21):
"""
dataframe = self.convert_to_dataframe(historical_data)
bollinger_data = abstract.BBANDS(dataframe, period_count)
bollinger_data.dropna(how='all', inplace=True)
return bollinger_data
bb_columns = {
'upperband': [numpy.nan] * dataframe.index.shape[0],
'middleband': [numpy.nan] * dataframe.index.shape[0],
'lowerband': [numpy.nan] * dataframe.index.shape[0]
}
bb_values = pandas.DataFrame(
bb_columns,
index=dataframe.index
)
bb_df_size = bb_values.shape[0]
bb_data = tulipy.bbands(numpy.array(dataframe['close']), period_count, 2)
for index in range(period_count, bb_df_size):
data_index = index - period_count
bb_values['upperband'][index] = bb_data[0][data_index]
bb_values['middleband'][index] = bb_data[1][data_index]
bb_values['lowerband'][index] = bb_data[2][data_index]
bb_values.dropna(how='all', inplace=True)
return bb_values
@@ -0,0 +1,2 @@
numpy==1.14.0
Cython==0.28.2
@@ -13,3 +13,4 @@ webcord==0.2
jinja2==2.10
requests==2.18.4
PyYAML==3.12
tulipy==0.2.1

0 comments on commit da22472

Please sign in to comment.