Remove Hyperopt methods

This commit is contained in:
Gerald Lonlas
2018-01-25 21:27:03 -08:00
parent 8e41050af9
commit c56fe7a76e
4 changed files with 0 additions and 316 deletions
-51
View File
@@ -87,54 +87,3 @@ class CustomStrategy(IStrategy):
),
'sell'] = 1
return dataframe
def hyperopt_space(self) -> List[Dict]:
"""
Define your Hyperopt space for the strategy
:return: Dict
"""
space = {
'ha_close_ema20': hp.choice('ha_close_ema20', [
{'enabled': False},
{'enabled': True}
]),
'ha_open_close': hp.choice('ha_open_close', [
{'enabled': False},
{'enabled': True}
]),
'trigger': hp.choice('trigger', [
{'type': 'ema50_cross_ema100'},
{'type': 'ema5_cross_ema10'},
]),
'stoploss': hp.uniform('stoploss', -0.5, -0.01),
}
return space
def buy_strategy_generator(self, params) -> None:
"""
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
conditions = []
# GUARDS AND TRENDS
if 'ha_close_ema20' in params and params['ha_close_ema20']['enabled']:
conditions.append(dataframe['ha_close'] > dataframe['ema20'])
if 'ha_open_close' in params and params['ha_open_close']['enabled']:
conditions.append(dataframe['ha_open'] < dataframe['ha_close'])
# TRIGGERS
triggers = {
'ema20_cross_ema50': (qtpylib.crossed_above(dataframe['ema20'], dataframe['ema50'])),
'ema50_cross_ema100': (qtpylib.crossed_above(dataframe['ema50'], dataframe['ema100'])),
}
conditions.append(triggers.get(params['trigger']['type']))
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'buy'] = 1
return dataframe
return populate_buy_trend
-60
View File
@@ -66,9 +66,6 @@ class CustomStrategy(IStrategy):
# SAR Parabol
dataframe['sar'] = ta.SAR(dataframe)
# TEMA - Triple Exponential Moving Average
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
# Hammer: values [0, 100]
dataframe['CDLHAMMER'] = ta.CDLHAMMER(dataframe)
@@ -104,60 +101,3 @@ class CustomStrategy(IStrategy):
),
'sell'] = 1
return dataframe
def hyperopt_space(self) -> List[Dict]:
"""
Define your Hyperopt space for the strategy
:return: Dict
"""
space = {
'rsi_lt': hp.choice('rsi_lt', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('rsi_lt-value', 20, 40, 1)}
]),
'slowk_lt': hp.choice('slowk_lt', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('slowk_lt-value', 0, 50, 1)}
]),
'CDLHAMMER': hp.choice('CDLHAMMER', [
{'enabled': False},
{'enabled': True}
]),
'trigger': hp.choice('trigger', [
{'type': 'lower_bb'},
{'type': 'lower_bb_tema'},
]),
'stoploss': hp.uniform('stoploss', -0.5, -0.01),
}
return space
def buy_strategy_generator(self, params) -> None:
"""
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
conditions = []
# GUARDS AND TRENDS
if 'rsi_lt' in params and params['rsi_lt']['enabled']:
conditions.append(dataframe['rsi'] < params['rsi_lt']['value'])
if 'slowk_lt' in params and params['slowk_lt']['enabled']:
conditions.append(dataframe['slowk'] < params['slowk_lt']['value'])
if 'CDLHAMMER' in params and params['CDLHAMMER']['enabled']:
conditions.append(dataframe['CDLHAMMER'] == 100)
# TRIGGERS
triggers = {
'lower_bb': (dataframe['close'] < dataframe['bb_lowerband']),
'lower_bb_tema': (dataframe['tema'] < dataframe['bb_lowerband']),
}
conditions.append(triggers.get(params['trigger']['type']))
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'buy'] = 1
return dataframe
return populate_buy_trend
-115
View File
@@ -48,10 +48,6 @@ class CustomStrategy(IStrategy):
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
"""
# Stoch
stoch = ta.STOCH(dataframe)
dataframe['slowk'] = stoch['slowk']
# MFI
dataframe['mfi'] = ta.MFI(dataframe)
@@ -74,7 +70,6 @@ class CustomStrategy(IStrategy):
# EMA - Exponential Moving Average
dataframe['ema5'] = ta.EMA(dataframe, timeperiod=5)
dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10)
dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
@@ -84,12 +79,6 @@ class CustomStrategy(IStrategy):
# SMA - Simple Moving Average
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
# TEMA - Triple Exponential Moving Average
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
# Hammer: values [0, 100]
dataframe['CDLHAMMER'] = ta.CDLHAMMER(dataframe)
return dataframe
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
@@ -129,107 +118,3 @@ class CustomStrategy(IStrategy):
),
'sell'] = 1
return dataframe
def hyperopt_space(self) -> List[Dict]:
"""
Define your Hyperopt space for the strategy
:return: Dict
"""
space = {
'rsi_gt': hp.choice('rsi_gt', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('rsi_gt-value', 0, 40, 1)}
]),
'rsi_lt': hp.choice('rsi_lt', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('rsi_lt-value', 20, 40, 1)}
]),
'close_sma': hp.choice('close_sma', [
{'enabled': False},
{'enabled': True}
]),
'fisher_rsi': hp.choice('fisher_rsi', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('fisher_rsi-value', -1, 1, 0.1)}
]),
'mfi': hp.choice('mfi', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('mfi-value', 5, 25, 1)}
]),
'fastd_fastk': hp.choice('fastd_fastk', [
{'enabled': False},
{'enabled': True}
]),
'fastd_gt0': hp.choice('fastd_gt0', [
{'enabled': False},
{'enabled': True}
]),
'trigger': hp.choice('trigger', [
{'type': 'ema5_cross_ema10'},
{'type': 'ema20_cross_ema50'},
{'type': 'ema50_cross_ema100'},
{'type': 'faststoch10'},
{'type': 'sar_reversal'},
{'type': 'stochf_cross'},
]),
'stoploss': hp.uniform('stoploss', -0.5, -0.01),
}
return space
def buy_strategy_generator(self, params) -> None:
"""
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
conditions = []
# GUARDS AND TRENDS
if 'rsi_gt' in params and params['rsi_gt']['enabled']:
conditions.append(dataframe['rsi'] > params['rsi_gt']['value'])
if 'rsi_lt' in params and params['rsi_lt']['enabled']:
conditions.append(dataframe['rsi'] < params['rsi_lt']['value'])
if 'close_sma' in params and params['close_sma']['enabled']:
conditions.append(dataframe['close'] < dataframe['sma'])
if 'fisher_rsi' in params and params['fisher_rsi']['enabled']:
conditions.append(
dataframe['fisher_rsi'] < params['fisher_rsi']['value']
)
if 'fastd_fastk' in params and params['fastd_fastk']['enabled']:
conditions.append(dataframe['fastd'] > dataframe['fastk'])
if 'fastd_gt0' in params and params['fastd_gt0']['enabled']:
conditions.append(dataframe['fastd'] > 0)
# TRIGGERS
triggers = {
'ema5_cross_ema10': (qtpylib.crossed_above(
dataframe['ema5'], dataframe['ema10']
)),
'ema20_cross_ema50': (qtpylib.crossed_above(
dataframe['ema20'], dataframe['ema50']
)),
'ema50_cross_ema100': (qtpylib.crossed_above(
dataframe['ema50'], dataframe['ema100']
)),
'faststoch10': (qtpylib.crossed_above(
dataframe['fastd'], 10.0
)),
'stochf_cross': (qtpylib.crossed_above(
dataframe['fastk'], dataframe['fastd']
)),
'sar_reversal': (qtpylib.crossed_above(
dataframe['close'], dataframe['sar']
)),
}
conditions.append(triggers.get(params['trigger']['type']))
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'buy'] = 1
return dataframe
return populate_buy_trend
-90
View File
@@ -119,93 +119,3 @@ class CustomStrategy(IStrategy):
),
'sell'] = 1
return dataframe
def hyperopt_space(self) -> List[Dict]:
"""
Define your Hyperopt space for the strategy
:return: Dict
"""
space = {
'adx': hp.choice('adx', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('adx-value', 20, 80, 1)}
]),
'slowadx': hp.choice('slowadx', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('slowadx-value', 20, 80, 1)}
]),
'cci': hp.choice('cci', [
{'enabled': False},
{'enabled': True}
]),
'fastkd': hp.choice('fastkd', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('fastkd-value', 0, 80, 1)}
]),
'slowfastkd': hp.choice('slowfastkd', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('slowfastkd-value', 0, 80, 1)}
]),
'fastk_fastd_prev': hp.choice('fastk_fastd_prev', [
{'enabled': False},
{'enabled': True}
]),
'meanvolume': hp.choice('meanvolume', [
{'enabled': False},
{'enabled': True, 'value': hp.quniform('meanvolume-value', 0.0, 1.0, 1)}
]),
'trigger': hp.choice('trigger', [
{'type': 'fastk_fastd'},
]),
'stoploss': hp.uniform('stoploss', -0.5, -0.01),
}
return space
def buy_strategy_generator(self, params) -> None:
"""
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
conditions = []
# GUARDS AND TRENDS
if 'adx' in params and params['adx']['enabled']:
conditions.append(dataframe['adx'] > params['adx']['value'])
if 'slowadx' in params and params['slowadx']['enabled']:
conditions.append(dataframe['slowadx'] > params['slowadx']['value'])
if 'cci' in params and params['cci']['enabled']:
conditions.append(dataframe['cci'] == 100)
if 'fastkd' in params and params['fastkd']['enabled']:
conditions.append(
(dataframe['fastk-previous'] < params['fastkd']['value']) &
(dataframe['fastd-previous'] < params['fastkd']['value'])
)
if 'slowfastkd' in params and params['slowfastkd']['enabled']:
conditions.append(
(dataframe['fastk-previous'] < params['slowfastkd']['value']) &
(dataframe['fastd-previous'] < params['slowfastkd']['value'])
)
if 'fastk_fastd_prev' in params and params['fastk_fastd_prev']['enabled']:
conditions.append((dataframe['fastk-previous'] < dataframe['fastd-previous']))
if 'meanvolume' in params and params['meanvolume']['enabled']:
conditions.append(dataframe['mean-volume'] > params['meanvolume']['value'])
# TRIGGERS
triggers = {
'fastk_fastd': (dataframe['fastk'] > dataframe['fastd'])
}
conditions.append(triggers.get(params['trigger']['type']))
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'buy'] = 1
return dataframe
return populate_buy_trend