Simplify liquidation price calculation
This commit is contained in:
@@ -2055,23 +2055,23 @@ class Exchange:
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
def leverage_prep(
|
||||
def get_interest_rate(self) -> float:
|
||||
"""
|
||||
Calculate interest rate - necessary for Margin trading.
|
||||
"""
|
||||
return 0.0
|
||||
|
||||
def get_liquidation_price(
|
||||
self,
|
||||
pair: str,
|
||||
open_rate: float,
|
||||
amount: float, # quote currency, includes leverage
|
||||
leverage: float,
|
||||
is_short: bool
|
||||
) -> Tuple[float, Optional[float]]:
|
||||
) -> Optional[float]:
|
||||
|
||||
# if TradingMode == TradingMode.MARGIN:
|
||||
# interest_rate = self.get_interest_rate(
|
||||
# pair=pair,
|
||||
# open_rate=open_rate,
|
||||
# is_short=is_short
|
||||
# )
|
||||
if self.trading_mode == TradingMode.SPOT:
|
||||
return (0.0, None)
|
||||
if self.trading_mode in (TradingMode.SPOT, TradingMode.MARGIN):
|
||||
return None
|
||||
elif (
|
||||
self.margin_mode == MarginMode.ISOLATED and
|
||||
self.trading_mode == TradingMode.FUTURES
|
||||
@@ -2086,7 +2086,7 @@ class Exchange:
|
||||
mm_ex_1=0.0,
|
||||
upnl_ex_1=0.0,
|
||||
)
|
||||
return (0.0, isolated_liq)
|
||||
return isolated_liq
|
||||
else:
|
||||
raise OperationalException(
|
||||
"Freqtrade only supports isolated futures for leverage trading")
|
||||
@@ -2231,7 +2231,7 @@ class Exchange:
|
||||
return 0.0
|
||||
|
||||
@retrier
|
||||
def get_liquidation_price(
|
||||
def get_or_calculate_liquidation_price(
|
||||
self,
|
||||
pair: str,
|
||||
# Dry-run
|
||||
|
Reference in New Issue
Block a user