@@ -2054,6 +2054,7 @@ def execute_trade_exit(
20542054 exit_tag : str | None = None ,
20552055 ordertype : str | None = None ,
20562056 sub_trade_amt : float | None = None ,
2057+ skip_custom_exit_price : bool = False ,
20572058 ) -> bool :
20582059 """
20592060 Executes a trade exit for the given trade and limit
@@ -2080,26 +2081,29 @@ def execute_trade_exit(
20802081 ):
20812082 exit_type = "stoploss"
20822083
2084+ order_type = ordertype or self .strategy .order_types [exit_type ]
20832085 # set custom_exit_price if available
20842086 proposed_limit_rate = limit
2087+ custom_exit_price = limit
2088+
20852089 current_profit = trade .calc_profit_ratio (limit )
2086- custom_exit_price = strategy_safe_wrapper (
2087- self .strategy .custom_exit_price , default_retval = proposed_limit_rate
2088- )(
2089- pair = trade .pair ,
2090- trade = trade ,
2091- current_time = datetime .now (UTC ),
2092- proposed_rate = proposed_limit_rate ,
2093- current_profit = current_profit ,
2094- exit_tag = exit_reason ,
2095- )
2090+ if order_type == "limit" and not skip_custom_exit_price :
2091+ custom_exit_price = strategy_safe_wrapper (
2092+ self .strategy .custom_exit_price , default_retval = proposed_limit_rate
2093+ )(
2094+ pair = trade .pair ,
2095+ trade = trade ,
2096+ current_time = datetime .now (UTC ),
2097+ proposed_rate = proposed_limit_rate ,
2098+ current_profit = current_profit ,
2099+ exit_tag = exit_reason ,
2100+ )
20962101
20972102 limit = self .get_valid_price (custom_exit_price , proposed_limit_rate )
20982103
20992104 # First cancelling stoploss on exchange ...
21002105 trade = self .cancel_stoploss_on_exchange (trade , allow_nonblocking = True )
21012106
2102- order_type = ordertype or self .strategy .order_types [exit_type ]
21032107 if exit_check .exit_type == ExitType .EMERGENCY_EXIT :
21042108 # Emergency exits (default to market!)
21052109 order_type = self .strategy .order_types .get ("emergency_exit" , "market" )
0 commit comments