From 10b52c1ed50d53cb3974ac864fb5408f300c4e5b Mon Sep 17 00:00:00 2001 From: lenik terenin Date: Mon, 9 Aug 2021 03:02:53 +0900 Subject: [PATCH 1/2] 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/2] 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'