add SAR to hyperopt. add over/under sma options to hyperopt
This commit is contained in:
parent
1196983d5f
commit
3f7a583de6
@ -31,12 +31,13 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
"""
|
||||
dataframe['sar'] = ta.SAR(dataframe)
|
||||
dataframe['adx'] = ta.ADX(dataframe)
|
||||
stoch = ta.STOCHF(dataframe)
|
||||
dataframe['fastd'] = stoch['fastd']
|
||||
dataframe['fastk'] = stoch['fastk']
|
||||
dataframe['blower'] = ta.BBANDS(dataframe, nbdevup=2, nbdevdn=2)['lowerband']
|
||||
dataframe['sma'] = ta.SMA(dataframe, timeperiod=30)
|
||||
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
||||
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
|
||||
dataframe['mfi'] = ta.MFI(dataframe)
|
||||
return dataframe
|
||||
|
@ -84,6 +84,8 @@ def buy_strategy_generator(params):
|
||||
conditions = []
|
||||
if params['below_sma']['enabled']:
|
||||
conditions.append(dataframe['close'] < dataframe['sma'])
|
||||
if params['over_sma']['enabled']:
|
||||
conditions.append(dataframe['close'] > dataframe['sma'])
|
||||
conditions.append(dataframe['tema'] <= dataframe['blower'])
|
||||
if params['mfi']['enabled']:
|
||||
conditions.append(dataframe['mfi'] < params['mfi']['value'])
|
||||
@ -91,7 +93,8 @@ def buy_strategy_generator(params):
|
||||
conditions.append(dataframe['fastd'] < params['fastd']['value'])
|
||||
if params['adx']['enabled']:
|
||||
conditions.append(dataframe['adx'] > params['adx']['value'])
|
||||
|
||||
if params['over_sar']['enabled']:
|
||||
conditions.append(dataframe['close'] > dataframe['sar'])
|
||||
dataframe.loc[
|
||||
reduce(lambda x, y: x & y, conditions),
|
||||
'buy'] = 1
|
||||
@ -123,6 +126,14 @@ def test_hyperopt(conf, pairs, mocker):
|
||||
{'enabled': False},
|
||||
{'enabled': True}
|
||||
]),
|
||||
'over_sma': hp.choice('over_sma', [
|
||||
{'enabled': False},
|
||||
{'enabled': True}
|
||||
]),
|
||||
'over_sar': hp.choice('over_sar', [
|
||||
{'enabled': False},
|
||||
{'enabled': True}
|
||||
]),
|
||||
}
|
||||
|
||||
# print(hyperopt.pyll.stochastic.sample(space))
|
||||
|
Loading…
Reference in New Issue
Block a user