From cb3b0cf311d43583d18fe1b67878a8e1d286b834 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 4 Aug 2021 23:09:40 -0400 Subject: [PATCH] add custom_exit_price in interface and freqtradebot --- freqtrade/freqtradebot.py | 8 ++++++++ freqtrade/strategy/interface.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 2592ccc91..8d50b46e3 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1082,6 +1082,14 @@ class FreqtradeBot(LoggingMixin): and self.strategy.order_types['stoploss_on_exchange']: limit = trade.stop_loss + # set custom_exit_price if available + current_profit = trade.calc_profit_ratio(limit) + limit = strategy_safe_wrapper(self.strategy.custom_exit_price, + default_retval=limit)( + pair=trade.pair, trade=trade, + current_time=datetime.now(timezone.utc), + proposed_rate=limit, current_profit=current_profit) + # First cancelling stoploss on exchange ... if self.strategy.order_types.get('stoploss_on_exchange') and trade.stoploss_order_id: try: diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index f7d0a0aae..4c0e1c8a9 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -299,7 +299,7 @@ class IStrategy(ABC, HyperStrategyMixin): def custom_exit_price(self, pair: str, trade: Trade, current_time: datetime, proposed_rate: float, - current_rate: float, current_profit: float, **kwargs) -> float: + current_profit: float, **kwargs) -> float: """ Custom exit price logic, returning the new exit price.