From 330b67b85776ec90673153ea27921f59c1a4e64d Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Fri, 1 Sep 2017 21:39:22 +0300 Subject: [PATCH 1/3] add TA-lib dependency --- README.md | 1 + requirements.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6479bf8ea..bd01adcf2 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ if not feel free to raise a github issue. ##### Prerequisites * python3 * sqlite +* [TA-lib](https://github.com/mrjbq7/ta-lib#dependencies) binaries ##### Install ``` diff --git a/requirements.txt b/requirements.txt index 934380d1c..55467bb38 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,5 @@ matplotlib==2.0.2 PYQT5==5.9 scikit-learn==0.19.0 scipy==0.19.1 -stockstats==0.2.0 \ No newline at end of file +stockstats==0.2.0 +TA-Lib==0.4.10 \ No newline at end of file From 072593c756d17f6fcefb1b81d7ffa07b4a477f58 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Fri, 1 Sep 2017 21:40:12 +0300 Subject: [PATCH 2/3] only buy when parabolic sar shows bullish trend --- analyze.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/analyze.py b/analyze.py index 68b7fa1c6..df7414368 100644 --- a/analyze.py +++ b/analyze.py @@ -5,6 +5,8 @@ import arrow import requests from pandas.io.json import json_normalize from stockstats import StockDataFrame +import talib.abstract as ta + logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') @@ -41,6 +43,8 @@ def get_ticker_dataframe(pair): } for t in sorted(data['result'], key=lambda k: k['T']) if arrow.get(t['T']) > minimum_date] dataframe = StockDataFrame(json_normalize(data)) + dataframe['sar'] = ta.SAR(dataframe, 0.02, 0.2) + # calculate StochRSI window = 14 rsi = dataframe['rsi_{}'.format(window)] @@ -66,7 +70,8 @@ def populate_trends(dataframe): """ dataframe.loc[ (dataframe['stochrsi'] < 0.20) - & (dataframe['macd'] > dataframe['macds']), + & (dataframe['macd'] > dataframe['macds']) + & (dataframe['close'] > dataframe['sar']), 'underpriced' ] = 1 dataframe.loc[dataframe['underpriced'] == 1, 'buy'] = dataframe['close'] @@ -110,8 +115,9 @@ def plot_dataframe(dataframe, pair): fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True) fig.suptitle(pair, fontsize=14, fontweight='bold') ax1.plot(dataframe.index.values, dataframe['close'], label='close') - ax1.plot(dataframe.index.values, dataframe['close_30_ema'], label='EMA(60)') - ax1.plot(dataframe.index.values, dataframe['close_90_ema'], label='EMA(120)') + # ax1.plot(dataframe.index.values, dataframe['close_30_ema'], label='EMA(60)') + # ax1.plot(dataframe.index.values, dataframe['close_90_ema'], label='EMA(120)') + ax1.plot(dataframe.index.values, dataframe['sar'], 'rx', label='SAR') # ax1.plot(dataframe.index.values, dataframe['sell'], 'ro', label='sell') ax1.plot(dataframe.index.values, dataframe['buy'], 'bo', label='buy') ax1.legend() From e28e2f62cd09dd6e52678407583a48cec3aabc3d Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 3 Sep 2017 17:35:58 +0300 Subject: [PATCH 3/3] install TA-lib in Dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index f43f12e16..d29d81cf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,14 @@ FROM python:3.6.2 +RUN pip install numpy +RUN apt-get update +RUN apt-get -y install build-essential +RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz +RUN tar zxvf ta-lib-0.4.0-src.tar.gz +RUN cd ta-lib && ./configure && make && make install +RUN pip install TA-Lib +ENV LD_LIBRARY_PATH /usr/local/lib + RUN mkdir -p /freqtrade WORKDIR /freqtrade