Merge pull request #79 from gcarq/qtpylib
Include new indicators from qtpylib
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# pragma pylint: disable=missing-docstring
|
||||
import json
|
||||
import pytest
|
||||
import arrow
|
||||
from pandas import DataFrame
|
||||
@@ -6,31 +7,19 @@ from pandas import DataFrame
|
||||
from freqtrade.analyze import parse_ticker_dataframe, populate_buy_trend, populate_indicators, \
|
||||
get_buy_signal
|
||||
|
||||
RESULT_BITTREX = {
|
||||
'success': True,
|
||||
'message': '',
|
||||
'result': [
|
||||
{'O': 0.00065311, 'H': 0.00065311, 'L': 0.00065311, 'C': 0.00065311, 'V': 22.17210568, 'T': '2017-08-30T10:40:00', 'BV': 0.01448082},
|
||||
{'O': 0.00066194, 'H': 0.00066195, 'L': 0.00066194, 'C': 0.00066195, 'V': 33.4727437, 'T': '2017-08-30T10:34:00', 'BV': 0.02215696},
|
||||
{'O': 0.00065311, 'H': 0.00065311, 'L': 0.00065311, 'C': 0.00065311, 'V': 53.85127609, 'T': '2017-08-30T10:37:00', 'BV': 0.0351708},
|
||||
{'O': 0.00066194, 'H': 0.00066194, 'L': 0.00065311, 'C': 0.00065311, 'V': 46.29210665, 'T': '2017-08-30T10:42:00', 'BV': 0.03063118},
|
||||
]
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def result():
|
||||
return parse_ticker_dataframe(RESULT_BITTREX['result'], arrow.get('2017-08-30T10:00:00'))
|
||||
with open('freqtrade/tests/testdata/btc-eth.json') as data_file:
|
||||
data = json.load(data_file)
|
||||
|
||||
return parse_ticker_dataframe(data['result'], arrow.get('2017-08-30T10:00:00'))
|
||||
|
||||
def test_dataframe_has_correct_columns(result):
|
||||
assert result.columns.tolist() == \
|
||||
['close', 'high', 'low', 'open', 'date', 'volume']
|
||||
|
||||
def test_orders_by_date(result):
|
||||
assert result['date'].tolist() == \
|
||||
['2017-08-30T10:34:00',
|
||||
'2017-08-30T10:37:00',
|
||||
'2017-08-30T10:40:00',
|
||||
'2017-08-30T10:42:00']
|
||||
def test_dataframe_has_correct_length(result):
|
||||
assert len(result.index) == 5751
|
||||
|
||||
def test_populates_buy_trend(result):
|
||||
dataframe = populate_buy_trend(populate_indicators(result))
|
||||
|
@@ -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)))
|
||||
|
Reference in New Issue
Block a user