diff --git a/user_data/strategies/Heracles.py b/user_data/strategies/Heracles.py index 3eaed3d..1cdb3d4 100644 --- a/user_data/strategies/Heracles.py +++ b/user_data/strategies/Heracles.py @@ -9,7 +9,7 @@ # }, # IMPORTANT: INSTALL TA BEFOUR RUN(pip install ta) # -# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces roi buy sell --strategy Heracles +# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces roi buy --strategy Heracles # ###################################################################### # --- Do not remove these libs --- from freqtrade.strategy.hyper import IntParameter, DecimalParameter @@ -28,48 +28,41 @@ import numpy as np class Heracles(IStrategy): ########################################## RESULT PASTE PLACE ########################################## - # 18/100: 111 trades. 77/23/11 Wins/Draws/Losses. Avg profit 3.81%. Median profit 4.40%. Total profit 2114.06222218 USDT ( 42.28Σ%). Avg duration 3 days, 3:04:00 min. Objective: -16.78579 + # 10/100: 25 trades. 18/4/3 Wins/Draws/Losses. Avg profit 5.92%. Median profit 6.33%. Total profit 0.04888306 BTC ( 48.88Σ%). Avg duration 4 days, 6:24:00 min. Objective: -11.42103 # Buy hyperspace params: buy_params = { - "buy_crossed_indicator_shift": 5, - "buy_div": 3.61, - "buy_indicator_shift": 1, + "buy_crossed_indicator_shift": 9, + "buy_div_max": 0.75, + "buy_div_min": 0.16, + "buy_indicator_shift": 15, } # Sell hyperspace params: sell_params = { - "sell_atol": 0.30989, - "sell_crossed_indicator_shift": 2, - "sell_indicator_shift": 5, - "sell_rtol": 0.19449, } # ROI table: minimal_roi = { - "0": 0.725, - "889": 0.171, - "2776": 0.044, - "5299": 0 + "0": 0.598, + "644": 0.166, + "3269": 0.115, + "7289": 0 } + # Stoploss: - stoploss = -0.312 + stoploss = -0.256 + + # Optimal timeframe use it in your config + timeframe = '4h' ########################################## END RESULT PASTE PLACE ###################################### # buy params - buy_div = DecimalParameter(-5, 5, default=0.51844, decimals=4, space='buy') - buy_indicator_shift = IntParameter(-5, 5, default=4, space='buy') - buy_crossed_indicator_shift = IntParameter(-5, 5, default=1, space='buy') - - # sell params - sell_rtol = DecimalParameter(1.e-10, 1.e-0, default=0.05468, decimals=10, space='sell') - sell_atol = DecimalParameter(1.e-16, 1.e-0, default=0.00019, decimals=10, space='sell') - sell_indicator_shift = IntParameter(-5, 5, default=4, space='sell') - sell_crossed_indicator_shift = IntParameter(-5, 5, default=1, space='sell') - - # Optimal timeframe use it in your config - timeframe = '4h' + buy_div_min = DecimalParameter(0, 1, default=0.16, decimals=2, space='buy') + buy_div_max = DecimalParameter(0, 1, default=0.75, decimals=2, space='buy') + buy_indicator_shift = IntParameter(0, 20, default=16, space='buy') + buy_crossed_indicator_shift = IntParameter(0, 20, default=9, space='buy') def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe = dropna(dataframe) @@ -93,26 +86,6 @@ class Heracles(IStrategy): fillna=False ) - dataframe['trend_macd_signal'] = ta.trend.macd_signal( - dataframe['close'], - window_slow=26, - window_fast=12, - window_sign=9, - fillna=False - ) - - dataframe['trend_ema_fast'] = ta.trend.EMAIndicator( - close=dataframe['close'], window=12, fillna=False - ).ema_indicator() - - # for checking crossovers! - # but we dont need to crossovers we just calculate dividation - - # import matplotlib.pyplot as plt - # dataframe.iloc[:,6:].plot(subplots=False) - # plt.tight_layout() - # plt.show() - return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: @@ -126,16 +99,17 @@ class Heracles(IStrategy): DFIND = dataframe[IND] DFCRS = dataframe[CRS] + d = DFIND.shift(self.buy_indicator_shift.value).div( + DFCRS.shift(self.buy_crossed_indicator_shift.value)) + + # print(d.min(), "\t", d.max()) conditions.append( - DFIND.shift(self.buy_indicator_shift.value).div( - DFCRS.shift(self.buy_crossed_indicator_shift.value) - ) <= self.buy_div.value - ) + d.between(self.buy_div_min.value, self.buy_div_max.value)) if conditions: dataframe.loc[ reduce(lambda x, y: x & y, conditions), - 'buy'] = 1 + 'buy']=1 return dataframe @@ -143,25 +117,5 @@ class Heracles(IStrategy): """ Sell strategy Hyperopt will build and use. """ - conditions = [] - - IND = 'trend_ema_fast' - CRS = 'trend_macd_signal' - DFIND = dataframe[IND] - DFCRS = dataframe[CRS] - - conditions.append( - np.isclose( - DFIND.shift(self.sell_indicator_shift.value), - DFCRS.shift(self.sell_crossed_indicator_shift.value), - rtol=self.sell_rtol.value, - atol=self.sell_rtol.value - ) - ) - - if conditions: - dataframe.loc[ - reduce(lambda x, y: x & y, conditions), - 'sell']=1 return dataframe