From ed320bb2ace412d3b8039c3fc086aaa750167272 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 31 Jan 2022 13:51:26 -0600 Subject: [PATCH] exchange.get_liquidation_price check length of positions --- freqtrade/exchange/exchange.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 3ba791861..837a390ed 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1993,7 +1993,7 @@ class Exchange: wallet_balance: float, # Or margin balance mm_ex_1: float = 0.0, # (Binance) Cross only upnl_ex_1: float = 0.0, # (Binance) Cross only - ): + ) -> Optional[float]: """ Set's the margin mode on the exchange to cross or isolated for a specific pair :param pair: base/quote currency pair (e.g. "ADA/USDT") @@ -2020,8 +2020,11 @@ class Exchange: try: positions = self._api.fetch_positions([pair]) - pos = positions[0] - return pos['liquidationPrice'] + if len(positions) > 0: + pos = positions[0] + return pos['liquidationPrice'] + else: + return None except ccxt.DDoSProtection as e: raise DDosProtection(e) from e except (ccxt.NetworkError, ccxt.ExchangeError) as e: