From d84ece7258a0082628f4459c278851fcac7374c9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 9 Nov 2022 20:17:10 +0100 Subject: [PATCH] Use conditional orders for stop orders --- freqtrade/exchange/okx.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/freqtrade/exchange/okx.py b/freqtrade/exchange/okx.py index 4ff7f283b..5acf039cb 100644 --- a/freqtrade/exchange/okx.py +++ b/freqtrade/exchange/okx.py @@ -164,14 +164,17 @@ class Okx(Exchange): def _get_stop_params(self, side: BuySell, ordertype: str, stop_price: float) -> Dict: - params = super()._get_stop_params(side, ordertype, stop_price) + params = self._params.copy() + # Verify if stopPrice works for your exchange! + params.update({'stopLossPrice': stop_price}) + if self.trading_mode == TradingMode.FUTURES and self.margin_mode: params['tdMode'] = self.margin_mode.value params['posSide'] = self._get_posSide(side, True) return params def fetch_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict: - params1 = {'stop': True, 'ordType': 'trigger'} + params1 = {'stop': True, 'ordType': 'conditional'} for method in (self._api.fetch_open_orders, self._api.fetch_closed_orders, self._api.fetch_canceled_orders): try: @@ -204,5 +207,5 @@ class Okx(Exchange): return self.cancel_order( order_id=order_id, pair=pair, - params={'stop': True} + params={'ordType': 'conditional'} )