From 6c01542fed34a71f44ae3b4aa75a0c8bce0b302f Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Feb 2020 20:27:13 +0100 Subject: [PATCH] Ad check_sell_timeout --- freqtrade/freqtradebot.py | 6 +++++- freqtrade/strategy/interface.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index f458f91d6..aa41c2f2a 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -830,7 +830,11 @@ class FreqtradeBot: self.wallets.update() elif ((order['side'] == 'sell' and order['status'] == 'canceled') - or (self._check_timed_out('sell', order))): + or (self._check_timed_out('sell', order)) + or strategy_safe_wrapper(self.strategy.check_sell_timeout, + default_retval=False)(pair=trade.pair, + trade=trade, + order=order)): self.handle_timedout_limit_sell(trade, order) self.wallets.update() diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index de08b7cda..681d2ccfb 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -167,6 +167,24 @@ class IStrategy(ABC): """ return False + def check_sell_timeout(self, pair: str, trade: Trade, order: Dict, **kwargs) -> bool: + """ + Check sell timeout function callback. + This method can be used to override the sell-timeout. + It is called whenever a limit sell order has been created, + and is not yet fully filled. + Configuration options in `unfilledtimeout` will be verified before this, + so ensure to set these timeouts high enough. + + When not implemented by a strategy, this simply returns False. + :param pair: Pair the trade is for + :param trade: trade object. + :param order: Order dictionary as returned from CCXT. + :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. + :return bool: When True is returned, then the sell-order is cancelled. + """ + return False + def informative_pairs(self) -> List[Tuple[str, str]]: """ Define additional, informative pair/interval combinations to be cached from the exchange.