diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 5959e457e..4c660142b 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1079,8 +1079,11 @@ class Exchange: if not self._ft_has.get('stoploss_on_exchange'): raise OperationalException(f"stoploss is not implemented for {self.name}.") - return ((side == "sell" and stop_loss > float(order['stopPrice'])) or + return ( + order.get('stopPrice', None) is None + or ((side == "sell" and stop_loss > float(order['stopPrice'])) or (side == "buy" and stop_loss < float(order['stopPrice']))) + ) def _get_stop_order_type(self, user_order_type) -> Tuple[str, str]: diff --git a/freqtrade/exchange/huobi.py b/freqtrade/exchange/huobi.py index 714b154aa..fdb6050a3 100644 --- a/freqtrade/exchange/huobi.py +++ b/freqtrade/exchange/huobi.py @@ -23,19 +23,6 @@ class Huobi(Exchange): "l2_limit_range_required": False, } - def stoploss_adjust(self, stop_loss: float, order: Dict, side: str) -> bool: - """ - Verify stop_loss against stoploss-order value (limit or price) - Returns True if adjustment is necessary. - """ - return ( - order.get('stopPrice', None) is None - or ( - order['type'] == 'stop' - and stop_loss > float(order['stopPrice']) - ) - ) - def _get_stop_params(self, side: BuySell, ordertype: str, stop_price: float) -> Dict: params = self._params.copy() diff --git a/freqtrade/exchange/kucoin.py b/freqtrade/exchange/kucoin.py index 10b0f7c7e..6c7d7acfc 100644 --- a/freqtrade/exchange/kucoin.py +++ b/freqtrade/exchange/kucoin.py @@ -28,16 +28,6 @@ class Kucoin(Exchange): "ohlcv_candle_limit": 1500, } - def stoploss_adjust(self, stop_loss: float, order: Dict, side: str) -> bool: - """ - Verify stop_loss against stoploss-order value (limit or price) - Returns True if adjustment is necessary. - """ - return ( - order.get('stopPrice', None) is None - or stop_loss > float(order['stopPrice']) - ) - def _get_stop_params(self, side: BuySell, ordertype: str, stop_price: float) -> Dict: params = self._params.copy() diff --git a/tests/exchange/test_huobi.py b/tests/exchange/test_huobi.py index fc7c7cefb..2ce379a47 100644 --- a/tests/exchange/test_huobi.py +++ b/tests/exchange/test_huobi.py @@ -113,5 +113,4 @@ def test_stoploss_adjust_huobi(mocker, default_conf): assert exchange.stoploss_adjust(1501, order, 'sell') assert not exchange.stoploss_adjust(1499, order, 'sell') # Test with invalid order case - order['type'] = 'stop_loss' - assert not exchange.stoploss_adjust(1501, order, 'sell') + assert exchange.stoploss_adjust(1501, order, 'sell')