Merge pull request #7 from vertti/parabolic-sar

Use Parabolic SAR indicator to only buy when bullish trend
This commit is contained in:
Michael Egger 2017-09-04 11:45:10 +02:00 committed by GitHub
commit 1dc1018356
2 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -5,9 +5,9 @@ import arrow
import requests
from pandas.io.json import json_normalize
from pandas import DataFrame
# from stockstats import StockDataFrame
import talib.abstract as ta
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
@ -46,6 +46,8 @@ def get_ticker_dataframe(pair: str) -> DataFrame:
dataframe['close_30_ema'] = ta.EMA(dataframe, timeperiod=30)
dataframe['close_90_ema'] = ta.EMA(dataframe, timeperiod=90)
dataframe['sar'] = ta.SAR(dataframe, 0.02, 0.2)
# calculate StochRSI
stochrsi = ta.STOCHRSI(dataframe)
dataframe['stochrsi'] = stochrsi['fastd'] # values between 0-100, not 0-1
@ -73,7 +75,8 @@ def populate_trends(dataframe: DataFrame) -> DataFrame:
"""
dataframe.loc[
(dataframe['stochrsi'] < 20)
& (dataframe['macd'] > dataframe['macds']),
& (dataframe['macd'] > dataframe['macds'])
& (dataframe['close'] > dataframe['sar']),
'underpriced'
] = 1
dataframe.loc[dataframe['underpriced'] == 1, 'buy'] = dataframe['close']