Add support for trailing_stop_loss order_type
This commit is contained in:
parent
ef9977fc1e
commit
8daafc875d
@ -277,7 +277,7 @@ For example, if your strategy is using a 1h timeframe, and you only want to buy
|
|||||||
|
|
||||||
### Understand order_types
|
### Understand order_types
|
||||||
|
|
||||||
The `order_types` configuration parameter maps actions (`buy`, `sell`, `stoploss`, `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.
|
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
|
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 using market orders. It also allows to set the
|
||||||
@ -286,7 +286,7 @@ 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.
|
`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 4 values (`buy`, `sell`, `stoploss` and
|
If this is configured, the following 5 values (`buy`, `sell`, `stoploss`, `trailing_stop_loss` and
|
||||||
`stoploss_on_exchange`) need to be present, otherwise the bot will fail to start.
|
`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)
|
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)
|
||||||
@ -301,6 +301,7 @@ order_types = {
|
|||||||
"forcebuy": "market",
|
"forcebuy": "market",
|
||||||
"forcesell": "market",
|
"forcesell": "market",
|
||||||
"stoploss": "market",
|
"stoploss": "market",
|
||||||
|
"trailing_stop_loss": "limit",
|
||||||
"stoploss_on_exchange": False,
|
"stoploss_on_exchange": False,
|
||||||
"stoploss_on_exchange_interval": 60,
|
"stoploss_on_exchange_interval": 60,
|
||||||
"stoploss_on_exchange_limit_ratio": 0.99,
|
"stoploss_on_exchange_limit_ratio": 0.99,
|
||||||
@ -317,6 +318,7 @@ Configuration:
|
|||||||
"forcebuy": "market",
|
"forcebuy": "market",
|
||||||
"forcesell": "market",
|
"forcesell": "market",
|
||||||
"stoploss": "market",
|
"stoploss": "market",
|
||||||
|
"trailing_stop_loss": "limit",
|
||||||
"stoploss_on_exchange": false,
|
"stoploss_on_exchange": false,
|
||||||
"stoploss_on_exchange_interval": 60
|
"stoploss_on_exchange_interval": 60
|
||||||
}
|
}
|
||||||
|
@ -1141,8 +1141,10 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
:return: True if it succeeds (supported) False (not supported)
|
:return: True if it succeeds (supported) False (not supported)
|
||||||
"""
|
"""
|
||||||
sell_type = 'sell'
|
sell_type = 'sell'
|
||||||
if sell_reason in (SellType.STOP_LOSS, SellType.TRAILING_STOP_LOSS):
|
if sell_reason == SellType.STOP_LOSS:
|
||||||
sell_type = 'stoploss'
|
sell_type = 'stoploss'
|
||||||
|
elif sell_reason == SellType.TRAILING_STOP_LOSS:
|
||||||
|
sell_type = 'trailing_stop_loss'
|
||||||
|
|
||||||
# if stoploss is on exchange and we are on dry_run mode,
|
# if stoploss is on exchange and we are on dry_run mode,
|
||||||
# we consider the sell price stop price
|
# we consider the sell price stop price
|
||||||
|
@ -100,6 +100,7 @@ class IStrategy(ABC):
|
|||||||
'buy': 'limit',
|
'buy': 'limit',
|
||||||
'sell': 'limit',
|
'sell': 'limit',
|
||||||
'stoploss': 'limit',
|
'stoploss': 'limit',
|
||||||
|
'trailing_stop_loss': 'limit',
|
||||||
'stoploss_on_exchange': False,
|
'stoploss_on_exchange': False,
|
||||||
'stoploss_on_exchange_interval': 60,
|
'stoploss_on_exchange_interval': 60,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user