From a5161ad43391f906afa90c3d46c2cd6fa29b299a Mon Sep 17 00:00:00 2001 From: rextea Date: Tue, 16 Mar 2021 15:32:07 +0200 Subject: [PATCH] Add support for trailing_stop_loss order_type --- config_full.json.example | 1 + docs/configuration.md | 4 ++-- freqtrade/freqtradebot.py | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config_full.json.example b/config_full.json.example index 8366774c4..f6f0e4187 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -52,6 +52,7 @@ "forcesell": "market", "forcebuy": "market", "stoploss": "market", + "trailing_stop_loss": "limit", "stoploss_on_exchange": false, "stoploss_on_exchange_interval": 60 }, diff --git a/docs/configuration.md b/docs/configuration.md index 9fd0208b8..894091209 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -280,13 +280,13 @@ For example, if your strategy is using a 1h timeframe, and you only want to buy The `order_types` configuration parameter maps actions (`buy`, `sell`, `stoploss`, `trailing_stop_loss`, `emergencysell`, `forcesell`, `forcebuy`) to order-types (`market`, `limit`, ...) as well as configures stoploss to be on the exchange and defines stoploss on exchange update interval in seconds. This allows to buy using limit orders, sell using -limit-orders, and create stoplosses using market orders. It also allows to set the +limit-orders, and create stoplosses or trailing_stop_loss using market orders. It also allows to set the stoploss "on exchange" which means stoploss order would be placed immediately once the buy order is fulfilled. `order_types` set in the configuration file overwrites values set in the strategy as a whole, so you need to configure the whole `order_types` dictionary in one place. -If this is configured, the following 5 values (`buy`, `sell`, `stoploss`, `trailing_stop_loss` and +If this is configured, the following 4 values (`buy`, `sell`, `stoploss` and `stoploss_on_exchange`) need to be present, otherwise the bot will fail to start. For information on (`emergencysell`,`forcesell`, `forcebuy`, `stoploss_on_exchange`,`stoploss_on_exchange_interval`,`stoploss_on_exchange_limit_ratio`) please see stop loss documentation [stop loss on exchange](stoploss.md) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index b47041e4d..4852c2a48 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1144,7 +1144,10 @@ class FreqtradeBot(LoggingMixin): if sell_reason == SellType.STOP_LOSS: sell_type = 'stoploss' elif sell_reason == SellType.TRAILING_STOP_LOSS: - sell_type = 'trailing_stop_loss' + if 'trailing_stop_loss' in self.strategy.order_types: + sell_type = 'trailing_stop_loss' + else: + sell_type = 'stoploss' # if stoploss is on exchange and we are on dry_run mode, # we consider the sell price stop price