From a77337e4241245a8cb77f2c5cf47fe71f3bd5104 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Tue, 20 Apr 2021 10:37:45 +0300 Subject: [PATCH] Document IStrategy.custom_sell. --- docs/strategy-advanced.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/strategy-advanced.md b/docs/strategy-advanced.md index 96c927965..758d08fca 100644 --- a/docs/strategy-advanced.md +++ b/docs/strategy-advanced.md @@ -69,6 +69,20 @@ class AwesomeStrategy(IStrategy): See `custom_stoploss` examples below on how to access the saved dataframe columns +## Custom sell signal + +It is possible to define custom sell signals. This is very useful when we need to customize sell conditions for each individual trade. + +An example of how we can sell trades that were open longer than 1 day: + +``` python +class AwesomeStrategy(IStrategy): + def custom_sell(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, + current_profit: float, **kwargs) -> bool: + time_delta = datetime.datetime.utcnow() - trade.open_date_utc + return time_delta.days >= 1 +``` + ## Custom stoploss The stoploss price can only ever move upwards - if the stoploss value returned from `custom_stoploss` would result in a lower stoploss price than was previously set, it will be ignored. The traditional `stoploss` value serves as an absolute lower level and will be instated as the initial stoploss.