Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bb #296

Merged
2 commits merged into from May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions Dockerfile
Expand Up @@ -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"]
31 changes: 27 additions & 4 deletions app/analyzers/informants/bollinger_bands.py
Expand Up @@ -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

Expand All @@ -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
4 changes: 4 additions & 0 deletions app/outputs.py
Expand Up @@ -116,6 +116,8 @@ def to_csv(self, results, market_pair):
str: Completed CSV message
"""

logger.warn('WARNING: CSV output is deprecated and will be removed in a future version')

output = str()
for indicator_type in results:
for indicator in results[indicator_type]:
Expand Down Expand Up @@ -184,6 +186,8 @@ def to_json(self, results, market_pair):
str: Completed JSON message
"""

logger.warn('WARNING: JSON output is deprecated and will be removed in a future version')

for indicator_type in results:
for indicator in results[indicator_type]:
for index, analysis in enumerate(results[indicator_type][indicator]):
Expand Down
2 changes: 2 additions & 0 deletions app/requirements-step-1.txt
@@ -0,0 +1,2 @@
numpy==1.14.0
Cython==0.28.2
1 change: 1 addition & 0 deletions app/requirements.txt → app/requirements-step-2.txt
Expand Up @@ -13,3 +13,4 @@ webcord==0.2
jinja2==2.10
requests==2.18.4
PyYAML==3.12
tulipy==0.2.1
2 changes: 1 addition & 1 deletion docs/config.md
Expand Up @@ -26,7 +26,7 @@ description: Can be set to `DEBUG`, `INFO`, `WARN`, `ERROR`. Used to set the log
**output_mode**\
default: cli\
necessity: optional\
description: Can be set to `cli`, `csv` or `json`. This will specify the output format for events emitted by the app.
description: This option is deprecated and will be removed in a later version. Can be set to `cli`, `csv` or `json`. This will specify the output format for events emitted by the app.

**update_interval**\
default: 300\
Expand Down