From 768a24c375014f755fa857c4b09c8bf4e0154922 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 9 Dec 2020 07:45:41 +0100 Subject: [PATCH] Add stoplossvalue interface --- docs/strategy-advanced.md | 5 +++++ freqtrade/strategy/interface.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/docs/strategy-advanced.md b/docs/strategy-advanced.md index 359280694..85a5a6bc6 100644 --- a/docs/strategy-advanced.md +++ b/docs/strategy-advanced.md @@ -8,6 +8,11 @@ If you're just getting started, please be familiar with the methods described in !!! Note All callback methods described below should only be implemented in a strategy if they are actually used. +## Custom stoploss logic + +// TODO: Complete this section + + ## Custom order timeout rules Simple, timebased order-timeouts can be configured either via strategy or in the configuration in the `unfilledtimeout` section. diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 027c5d36e..33a7ef0c1 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -254,6 +254,24 @@ class IStrategy(ABC): """ return True + def stoploss_value(self, pair: str, trade: Trade, rate: float, **kwargs) -> float: + """ + Define custom stoploss logic + The custom stoploss can never be below self.stoploss, which serves as a hard maximum loss. + + + For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/ + + When not implemented by a strategy, returns the initial stoploss value + + :param pair: Pair that's about to be sold. + :param trade: trade object. + :param rate: Rate that's going to be used when using limit orders + :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. + :return float: New stoploss value, relative to the open price + """ + return self.stoploss + def informative_pairs(self) -> ListPairsWithTimeframes: """ Define additional, informative pair/interval combinations to be cached from the exchange.