From ff5b3c323adc07b7cded5cb38ac8f54b235b76a8 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 16 Feb 2022 09:02:11 +0100 Subject: [PATCH] Fix okx trading mode --- freqtrade/exchange/okx.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/freqtrade/exchange/okx.py b/freqtrade/exchange/okx.py index 8b71773be..99b19903b 100644 --- a/freqtrade/exchange/okx.py +++ b/freqtrade/exchange/okx.py @@ -32,6 +32,24 @@ class Okx(Exchange): (TradingMode.FUTURES, MarginMode.ISOLATED), ] + def _get_params( + self, + ordertype: str, + leverage: float, + reduceOnly: bool, + time_in_force: str = 'gtc', + ) -> Dict: + # TODO-lev: Test me + params = super()._get_params( + ordertype=ordertype, + leverage=leverage, + reduceOnly=reduceOnly, + time_in_force=time_in_force, + ) + if self.trading_mode == TradingMode.FUTURES and self.margin_mode: + params['tdMode'] = self.margin_mode.value + return params + @retrier def _lev_prep( self, @@ -45,6 +63,7 @@ class Okx(Exchange): f"{self.name}.margin_mode must be set for {self.trading_mode.value}" ) try: + # TODO-lev: Test me properly (check mgnMode passed) self._api.set_leverage( leverage=leverage, symbol=pair,