Align samples (hyperopt and strategy) to work together
This commit is contained in:
parent
861f10dca6
commit
97d0f93d3c
@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import Any, Callable, Dict, List
|
from typing import Any, Callable, Dict, List
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np # noqa
|
||||||
import talib.abstract as ta
|
import talib.abstract as ta
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
from skopt.space import Categorical, Dimension, Integer, Real
|
from skopt.space import Categorical, Dimension, Integer, Real # noqa
|
||||||
|
|
||||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
@ -34,34 +33,6 @@ class SampleHyperOpts(IHyperOpt):
|
|||||||
Sample implementation of these methods can be found in
|
Sample implementation of these methods can be found in
|
||||||
https://github.com/freqtrade/freqtrade/blob/develop/user_data/hyperopts/sample_hyperopt_advanced.py
|
https://github.com/freqtrade/freqtrade/blob/develop/user_data/hyperopts/sample_hyperopt_advanced.py
|
||||||
"""
|
"""
|
||||||
@staticmethod
|
|
||||||
def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
||||||
"""
|
|
||||||
Add several indicators needed for buy and sell strategies defined below.
|
|
||||||
"""
|
|
||||||
# ADX
|
|
||||||
dataframe['adx'] = ta.ADX(dataframe)
|
|
||||||
# MACD
|
|
||||||
macd = ta.MACD(dataframe)
|
|
||||||
dataframe['macd'] = macd['macd']
|
|
||||||
dataframe['macdsignal'] = macd['macdsignal']
|
|
||||||
# MFI
|
|
||||||
dataframe['mfi'] = ta.MFI(dataframe)
|
|
||||||
# RSI
|
|
||||||
dataframe['rsi'] = ta.RSI(dataframe)
|
|
||||||
# Stochastic Fast
|
|
||||||
stoch_fast = ta.STOCHF(dataframe)
|
|
||||||
dataframe['fastd'] = stoch_fast['fastd']
|
|
||||||
# Minus-DI
|
|
||||||
dataframe['minus_di'] = ta.MINUS_DI(dataframe)
|
|
||||||
# Bollinger bands
|
|
||||||
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
|
||||||
dataframe['bb_lowerband'] = bollinger['lower']
|
|
||||||
dataframe['bb_upperband'] = bollinger['upper']
|
|
||||||
# SAR
|
|
||||||
dataframe['sar'] = ta.SAR(dataframe)
|
|
||||||
|
|
||||||
return dataframe
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
@ -107,16 +107,16 @@ class SampleStrategy(IStrategy):
|
|||||||
# RSI
|
# RSI
|
||||||
dataframe['rsi'] = ta.RSI(dataframe)
|
dataframe['rsi'] = ta.RSI(dataframe)
|
||||||
|
|
||||||
"""
|
|
||||||
# ADX
|
# ADX
|
||||||
dataframe['adx'] = ta.ADX(dataframe)
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
"""
|
||||||
# Awesome oscillator
|
# Awesome oscillator
|
||||||
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe)
|
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe)
|
||||||
|
|
||||||
# Commodity Channel Index: values Oversold:<-100, Overbought:>100
|
# Commodity Channel Index: values Oversold:<-100, Overbought:>100
|
||||||
dataframe['cci'] = ta.CCI(dataframe)
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
"""
|
||||||
# MACD
|
# MACD
|
||||||
macd = ta.MACD(dataframe)
|
macd = ta.MACD(dataframe)
|
||||||
dataframe['macd'] = macd['macd']
|
dataframe['macd'] = macd['macd']
|
||||||
@ -126,6 +126,7 @@ class SampleStrategy(IStrategy):
|
|||||||
# MFI
|
# MFI
|
||||||
dataframe['mfi'] = ta.MFI(dataframe)
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
"""
|
||||||
# Minus Directional Indicator / Movement
|
# Minus Directional Indicator / Movement
|
||||||
dataframe['minus_dm'] = ta.MINUS_DM(dataframe)
|
dataframe['minus_dm'] = ta.MINUS_DM(dataframe)
|
||||||
dataframe['minus_di'] = ta.MINUS_DI(dataframe)
|
dataframe['minus_di'] = ta.MINUS_DI(dataframe)
|
||||||
@ -149,12 +150,13 @@ class SampleStrategy(IStrategy):
|
|||||||
stoch = ta.STOCH(dataframe)
|
stoch = ta.STOCH(dataframe)
|
||||||
dataframe['slowd'] = stoch['slowd']
|
dataframe['slowd'] = stoch['slowd']
|
||||||
dataframe['slowk'] = stoch['slowk']
|
dataframe['slowk'] = stoch['slowk']
|
||||||
|
"""
|
||||||
# Stoch fast
|
# Stoch fast
|
||||||
stoch_fast = ta.STOCHF(dataframe)
|
stoch_fast = ta.STOCHF(dataframe)
|
||||||
dataframe['fastd'] = stoch_fast['fastd']
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
dataframe['fastk'] = stoch_fast['fastk']
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
|
||||||
|
"""
|
||||||
# Stoch RSI
|
# Stoch RSI
|
||||||
stoch_rsi = ta.STOCHRSI(dataframe)
|
stoch_rsi = ta.STOCHRSI(dataframe)
|
||||||
dataframe['fastd_rsi'] = stoch_rsi['fastd']
|
dataframe['fastd_rsi'] = stoch_rsi['fastd']
|
||||||
@ -178,12 +180,11 @@ class SampleStrategy(IStrategy):
|
|||||||
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
|
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
|
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
|
||||||
|
|
||||||
# SAR Parabol
|
|
||||||
dataframe['sar'] = ta.SAR(dataframe)
|
|
||||||
|
|
||||||
# SMA - Simple Moving Average
|
# SMA - Simple Moving Average
|
||||||
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
||||||
"""
|
"""
|
||||||
|
# SAR Parabol
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
|
||||||
# TEMA - Triple Exponential Moving Average
|
# TEMA - Triple Exponential Moving Average
|
||||||
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
|
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
|
||||||
|
Loading…
Reference in New Issue
Block a user