From a078088ea39ee5abba7a482f6ae684bb92bb4d2b Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 20 Apr 2024 09:24:51 +0200 Subject: [PATCH] Fix some more default argument usage in exchange classes --- freqtrade/exchange/exchange.py | 7 +++++-- freqtrade/exchange/gate.py | 3 ++- freqtrade/exchange/okx.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index fbaa9f89f..033865af1 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1350,7 +1350,7 @@ class Exchange: and order.get('filled') == 0.0) @retrier - def cancel_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict: + def cancel_order(self, order_id: str, pair: str, params: Optional[Dict] = None) -> Dict: if self._config['dry_run']: try: order = self.fetch_dry_run_order(order_id) @@ -1360,6 +1360,8 @@ class Exchange: except InvalidOrderException: return {} + if params is None: + params = {} try: order = self._api.cancel_order(order_id, pair, params=params) self._log_exchange_response('cancel_order', order) @@ -1376,7 +1378,8 @@ class Exchange: except ccxt.BaseError as e: raise OperationalException(e) from e - def cancel_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict: + def cancel_stoploss_order( + self, order_id: str, pair: str, params: Optional[Dict] = None) -> Dict: return self.cancel_order(order_id, pair, params) def is_cancel_order_result_suitable(self, corder) -> bool: diff --git a/freqtrade/exchange/gate.py b/freqtrade/exchange/gate.py index 42e79e63e..e7d7cfc74 100644 --- a/freqtrade/exchange/gate.py +++ b/freqtrade/exchange/gate.py @@ -119,7 +119,8 @@ class Gate(Exchange): return order1 return order - def cancel_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict: + def cancel_stoploss_order( + self, order_id: str, pair: str, params: Optional[Dict] = None) -> Dict: return self.cancel_order( order_id=order_id, pair=pair, diff --git a/freqtrade/exchange/okx.py b/freqtrade/exchange/okx.py index 60b681f65..2677a3463 100644 --- a/freqtrade/exchange/okx.py +++ b/freqtrade/exchange/okx.py @@ -232,7 +232,8 @@ class Okx(Exchange): return safe_value_fallback2(order, order, 'id_stop', 'id') return order['id'] - def cancel_stoploss_order(self, order_id: str, pair: str, params: Dict = {}) -> Dict: + def cancel_stoploss_order( + self, order_id: str, pair: str, params: Optional[Dict] = None) -> Dict: params1 = {'stop': True} # 'ordType': 'conditional' #