diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 58321a2db..ac3edad89 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1983,6 +1983,26 @@ class Exchange: else: return 0.0 + @retrier + def get_liquidation_price(self, pair: str): + ''' + Set's the margin mode on the exchange to cross or isolated for a specific pair + :param symbol: base/quote currency pair (e.g. "ADA/USDT") + ''' + if self._config['dry_run'] or not self.exchange_has("fetchPositions"): + # Some exchanges only support one collateral type + return + + try: + return self._api.fetch_positions(pair).liquidationPrice + except ccxt.DDoSProtection as e: + raise DDosProtection(e) from e + except (ccxt.NetworkError, ccxt.ExchangeError) as e: + raise TemporaryError( + f'Could not set margin mode due to {e.__class__.__name__}. Message: {e}') from e + except ccxt.BaseError as e: + raise OperationalException(e) from e + def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool: return exchange_name in ccxt_exchanges(ccxt_module)