From 6ba2492360e81e2a8a8879bf6730ca6d4729a40e Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Wed, 25 Oct 2017 18:24:20 +0300 Subject: [PATCH] add Awesome Oscillator and try it in hyperopt --- freqtrade/analyze.py | 3 +++ freqtrade/tests/test_hyperopt.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index 310754754..3b9a870c3 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -5,6 +5,7 @@ from datetime import timedelta import arrow import talib.abstract as ta from pandas import DataFrame +from qtpylib.indicators import awesome_oscillator, crossed_above from freqtrade import exchange from freqtrade.exchange import Bittrex, get_ticker_history @@ -41,6 +42,8 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame: dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9) dataframe['mfi'] = ta.MFI(dataframe) dataframe['cci'] = ta.CCI(dataframe) + dataframe['ao'] = awesome_oscillator(dataframe) + return dataframe diff --git a/freqtrade/tests/test_hyperopt.py b/freqtrade/tests/test_hyperopt.py index 9a9df78e9..ceefb06ac 100644 --- a/freqtrade/tests/test_hyperopt.py +++ b/freqtrade/tests/test_hyperopt.py @@ -7,6 +7,7 @@ from functools import reduce import pytest import arrow from pandas import DataFrame +from qtpylib.indicators import crossed_above from hyperopt import fmin, tpe, hp @@ -63,6 +64,7 @@ def buy_strategy_generator(params): triggers = { 'lower_bb': dataframe['tema'] <= dataframe['blower'], 'faststoch10': (dataframe['fastd'] >= 10) & (prev_fastd < 10), + 'ao_cross_zero': (crossed_above(dataframe['ao'], 0.0)), } conditions.append(triggers.get(params['trigger']['type'])) @@ -124,7 +126,8 @@ def test_hyperopt(conf, pairs, mocker): ]), 'trigger': hp.choice('trigger', [ {'type': 'lower_bb'}, - {'type': 'faststoch10'} + {'type': 'faststoch10'}, + {'type': 'ao_cross_zero'} ]), } print('Best parameters {}'.format(fmin(fn=optimizer, space=space, algo=tpe.suggest, max_evals=40)))