From 10b52c1ed50d53cb3974ac864fb5408f300c4e5b Mon Sep 17 00:00:00 2001 From: lenik terenin Date: Mon, 9 Aug 2021 03:02:53 +0900 Subject: [PATCH 1/6] Create BreakEven.py --- user_data/strategies/BreakEven.py | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 user_data/strategies/BreakEven.py diff --git a/user_data/strategies/BreakEven.py b/user_data/strategies/BreakEven.py new file mode 100644 index 0000000..e3519f4 --- /dev/null +++ b/user_data/strategies/BreakEven.py @@ -0,0 +1,67 @@ +# --- Do not remove these libs --- +from freqtrade.strategy.interface import IStrategy +from pandas import DataFrame +# -------------------------------- + + +class BreakEven(IStrategy): + """ + author@: lenik + + Sometimes I want to close the bot ASAP, but not have the positions floating around. + + I can "/stopbuy" and wait for the positions to get closed by the bot rules, which is + waiting for some profit, etc -- this usually takes too long... + + What I would prefer is to close everything that is over 0% profit to avoid the losses. + + Here's a simple strategy with empty buy/sell signals and "minimal_roi = { 0 : 0 }" that + sells everything already at profit and wait until the positions at loss will come to break + even point (or the small profit you provide in ROI table). + + You may restart the bot with the new strategy as a command-line parameter. + + Another way would be to specify the original strategy in the config file, then change to + this one and simply "/reload_config" from the Telegram bot. + + """ + + # This attribute will be overridden if the config file contains "minimal_roi" + minimal_roi = { + "0": 0.01, # at least 1% at first + "10": 0 # after 10min, everything goes + } + + # This is more radical version that sells everything above the profit level +# minimal_roi = { +# "0": 0 +# } + + # And this is basically "/forcesell all", that sells no matter what profit +# minimal_roi = { +# "0": -1 +# } + + # Optimal stoploss designed for the strategy + stoploss = -0.25 + + # Optimal timeframe for the strategy + timeframe = '5m' + + # don't generate any buy or sell signals, everything is handled by ROI and stop_loss + def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + return dataframe + + def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[ + ( + ), + 'buy'] = 0 + return dataframe + + def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[ + ( + ), + 'sell'] = 0 + return dataframe From 7f31b06724c40d6c5e13cddecba454631f8e8f91 Mon Sep 17 00:00:00 2001 From: lenik terenin Date: Mon, 9 Aug 2021 03:56:35 +0900 Subject: [PATCH 2/6] Update BreakEven.py 25% stop loss -> 5%, to cut unrecoverable losses faster --- user_data/strategies/BreakEven.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_data/strategies/BreakEven.py b/user_data/strategies/BreakEven.py index e3519f4..b405890 100644 --- a/user_data/strategies/BreakEven.py +++ b/user_data/strategies/BreakEven.py @@ -43,7 +43,7 @@ class BreakEven(IStrategy): # } # Optimal stoploss designed for the strategy - stoploss = -0.25 + stoploss = -0.05 # Optimal timeframe for the strategy timeframe = '5m' From a2d714b473000712ca648f333de67b23e83a4cc5 Mon Sep 17 00:00:00 2001 From: Maxime Puys Date: Tue, 10 Aug 2021 13:27:37 +0200 Subject: [PATCH 3/6] Updated: hyperoptable parameters for CofiBitStrategy --- .../berlinguyinca/CofiBitStrategy.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/user_data/strategies/berlinguyinca/CofiBitStrategy.py b/user_data/strategies/berlinguyinca/CofiBitStrategy.py index 4058139..b81910d 100644 --- a/user_data/strategies/berlinguyinca/CofiBitStrategy.py +++ b/user_data/strategies/berlinguyinca/CofiBitStrategy.py @@ -2,6 +2,7 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib import talib.abstract as ta from freqtrade.strategy.interface import IStrategy +from freqtrade.strategy import IntParameter from pandas import DataFrame @@ -12,6 +13,16 @@ class CofiBitStrategy(IStrategy): """ taken from slack by user CofiBit """ + + # Buy hyperspace params: + buy_params = { + "buy_lim": 25, + } + + # Sell hyperspace params: + sell_params = { + "sell_lim": 75, + } # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi" @@ -29,6 +40,9 @@ class CofiBitStrategy(IStrategy): # Optimal timeframe for the strategy timeframe = '5m' + buy_lim = IntParameter(20, 30, default=25) + sell_lim = IntParameter(70, 80, default=75) + def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0) dataframe['fastd'] = stoch_fast['fastd'] @@ -51,9 +65,9 @@ class CofiBitStrategy(IStrategy): (dataframe['open'] < dataframe['ema_low']) & (qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd'])) & # (dataframe['fastk'] > dataframe['fastd']) & - (dataframe['fastk'] < 30) & - (dataframe['fastd'] < 30) & - (dataframe['adx'] > 30) + (dataframe['fastk'] < self.buy_lim.value) & + (dataframe['fastd'] < self.buy_lim.value) & + (dataframe['adx'] > self.buy_lim.value) ), 'buy'] = 1 @@ -70,10 +84,10 @@ class CofiBitStrategy(IStrategy): (dataframe['open'] >= dataframe['ema_high']) ) | ( - # (dataframe['fastk'] > 70) & - # (dataframe['fastd'] > 70) - (qtpylib.crossed_above(dataframe['fastk'], 70)) | - (qtpylib.crossed_above(dataframe['fastd'], 70)) + # (dataframe['fastk'] > self.sell_lim.value) & + # (dataframe['fastd'] > self.sell_lim.value) + (qtpylib.crossed_above(dataframe['fastk'], self.sell_lim.value)) | + (qtpylib.crossed_above(dataframe['fastd'], self.sell_lim.value)) ), 'sell'] = 1 From 459f82828fc6671dfb8acf45f06ed922b6f160b2 Mon Sep 17 00:00:00 2001 From: Maxime Puys Date: Wed, 11 Aug 2021 18:55:53 +0200 Subject: [PATCH 4/6] Updated: hyperoptable parameters for CofiBitStrategy with ADX separated --- .../berlinguyinca/CofiBitStrategy.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/user_data/strategies/berlinguyinca/CofiBitStrategy.py b/user_data/strategies/berlinguyinca/CofiBitStrategy.py index b81910d..8f86059 100644 --- a/user_data/strategies/berlinguyinca/CofiBitStrategy.py +++ b/user_data/strategies/berlinguyinca/CofiBitStrategy.py @@ -16,12 +16,13 @@ class CofiBitStrategy(IStrategy): # Buy hyperspace params: buy_params = { - "buy_lim": 25, + "buy_fastx": 25, + "buy_adx": 25, } # Sell hyperspace params: sell_params = { - "sell_lim": 75, + "sell_fastx": 75, } # Minimal ROI designed for the strategy. @@ -40,8 +41,9 @@ class CofiBitStrategy(IStrategy): # Optimal timeframe for the strategy timeframe = '5m' - buy_lim = IntParameter(20, 30, default=25) - sell_lim = IntParameter(70, 80, default=75) + buy_fastx = IntParameter(20, 30, default=25) + buy_adx = IntParameter(20, 30, default=25) + sell_fastx = IntParameter(70, 80, default=75) def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0) @@ -64,10 +66,9 @@ class CofiBitStrategy(IStrategy): ( (dataframe['open'] < dataframe['ema_low']) & (qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd'])) & - # (dataframe['fastk'] > dataframe['fastd']) & - (dataframe['fastk'] < self.buy_lim.value) & - (dataframe['fastd'] < self.buy_lim.value) & - (dataframe['adx'] > self.buy_lim.value) + (dataframe['fastk'] < self.buy_fastx.value) & + (dataframe['fastd'] < self.buy_fastx.value) & + (dataframe['adx'] > self.buy_adx.value) ), 'buy'] = 1 @@ -84,10 +85,8 @@ class CofiBitStrategy(IStrategy): (dataframe['open'] >= dataframe['ema_high']) ) | ( - # (dataframe['fastk'] > self.sell_lim.value) & - # (dataframe['fastd'] > self.sell_lim.value) - (qtpylib.crossed_above(dataframe['fastk'], self.sell_lim.value)) | - (qtpylib.crossed_above(dataframe['fastd'], self.sell_lim.value)) + (qtpylib.crossed_above(dataframe['fastk'], self.sell_fastx.value)) | + (qtpylib.crossed_above(dataframe['fastd'], self.sell_fastx.value)) ), 'sell'] = 1 From 0ed25b16e871c6a8a2dbcf49df7fb23bcb1e7310 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 14 Aug 2021 16:13:21 +0200 Subject: [PATCH 5/6] Update command to not use hyperopt file in mabStra --- user_data/strategies/mabStra.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_data/strategies/mabStra.py b/user_data/strategies/mabStra.py index d2615cc..a9b7eb4 100644 --- a/user_data/strategies/mabStra.py +++ b/user_data/strategies/mabStra.py @@ -1,7 +1,7 @@ # Author: @Mablue (Masoud Azizi) # github: https://github.com/mablue/ # IMPORTANT: DO NOT USE IT WITHOUT HYPEROPT: -# freqtrade hyperopt --hyperopt mabStraHo --hyperopt-loss SharpeHyperOptLoss --spaces all --strategy mabStra --config config.json -e 100 +# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLoss --spaces all --strategy mabStra --config config.json -e 100 # --- Do not remove these libs --- from freqtrade.strategy.hyper import IntParameter, DecimalParameter @@ -11,7 +11,6 @@ from pandas import DataFrame # Add your lib to import here import talib.abstract as ta -import freqtrade.vendor.qtpylib.indicators as qtpylib class mabStra(IStrategy): From 52dc9406560dc196fad8716e4c6449dccb46deb3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 15 Aug 2021 08:14:45 +0200 Subject: [PATCH 6/6] Add minimal_roi --- user_data/strategies/mabStra.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_data/strategies/mabStra.py b/user_data/strategies/mabStra.py index a9b7eb4..7900aa9 100644 --- a/user_data/strategies/mabStra.py +++ b/user_data/strategies/mabStra.py @@ -14,6 +14,10 @@ import talib.abstract as ta class mabStra(IStrategy): + minimal_roi = { + "0": 0.05, + } + # buy params buy_mojo_ma_timeframe = IntParameter(2, 100, default=7, space='buy') buy_fast_ma_timeframe = IntParameter(2, 100, default=14, space='buy')