feat: Don't run custom_exit_price callback when exiting with price
This commit is contained in:
+15
-11
@@ -2054,6 +2054,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
exit_tag: str | None = None,
|
exit_tag: str | None = None,
|
||||||
ordertype: str | None = None,
|
ordertype: str | None = None,
|
||||||
sub_trade_amt: float | None = None,
|
sub_trade_amt: float | None = None,
|
||||||
|
skip_custom_exit_price: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Executes a trade exit for the given trade and limit
|
Executes a trade exit for the given trade and limit
|
||||||
@@ -2080,26 +2081,29 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
):
|
):
|
||||||
exit_type = "stoploss"
|
exit_type = "stoploss"
|
||||||
|
|
||||||
|
order_type = ordertype or self.strategy.order_types[exit_type]
|
||||||
# set custom_exit_price if available
|
# set custom_exit_price if available
|
||||||
proposed_limit_rate = limit
|
proposed_limit_rate = limit
|
||||||
|
custom_exit_price = limit
|
||||||
|
|
||||||
current_profit = trade.calc_profit_ratio(limit)
|
current_profit = trade.calc_profit_ratio(limit)
|
||||||
custom_exit_price = strategy_safe_wrapper(
|
if order_type == "limit" and not skip_custom_exit_price:
|
||||||
self.strategy.custom_exit_price, default_retval=proposed_limit_rate
|
custom_exit_price = strategy_safe_wrapper(
|
||||||
)(
|
self.strategy.custom_exit_price, default_retval=proposed_limit_rate
|
||||||
pair=trade.pair,
|
)(
|
||||||
trade=trade,
|
pair=trade.pair,
|
||||||
current_time=datetime.now(UTC),
|
trade=trade,
|
||||||
proposed_rate=proposed_limit_rate,
|
current_time=datetime.now(UTC),
|
||||||
current_profit=current_profit,
|
proposed_rate=proposed_limit_rate,
|
||||||
exit_tag=exit_reason,
|
current_profit=current_profit,
|
||||||
)
|
exit_tag=exit_reason,
|
||||||
|
)
|
||||||
|
|
||||||
limit = self.get_valid_price(custom_exit_price, proposed_limit_rate)
|
limit = self.get_valid_price(custom_exit_price, proposed_limit_rate)
|
||||||
|
|
||||||
# First cancelling stoploss on exchange ...
|
# First cancelling stoploss on exchange ...
|
||||||
trade = self.cancel_stoploss_on_exchange(trade, allow_nonblocking=True)
|
trade = self.cancel_stoploss_on_exchange(trade, allow_nonblocking=True)
|
||||||
|
|
||||||
order_type = ordertype or self.strategy.order_types[exit_type]
|
|
||||||
if exit_check.exit_type == ExitType.EMERGENCY_EXIT:
|
if exit_check.exit_type == ExitType.EMERGENCY_EXIT:
|
||||||
# Emergency exits (default to market!)
|
# Emergency exits (default to market!)
|
||||||
order_type = self.strategy.order_types.get("emergency_exit", "market")
|
order_type = self.strategy.order_types.get("emergency_exit", "market")
|
||||||
|
|||||||
@@ -992,7 +992,12 @@ class RPC:
|
|||||||
sub_amount = amount
|
sub_amount = amount
|
||||||
|
|
||||||
self._freqtrade.execute_trade_exit(
|
self._freqtrade.execute_trade_exit(
|
||||||
trade, current_rate, exit_check, ordertype=order_type, sub_trade_amt=sub_amount
|
trade,
|
||||||
|
current_rate,
|
||||||
|
exit_check,
|
||||||
|
ordertype=order_type,
|
||||||
|
sub_trade_amt=sub_amount,
|
||||||
|
skip_custom_exit_price=price is not None and ordertype == "limit",
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user