Simplify liquidation price calling structure
This commit is contained in:
@@ -2432,36 +2432,6 @@ class Exchange:
|
||||
"""
|
||||
return 0.0
|
||||
|
||||
def get_liquidation_price(
|
||||
self,
|
||||
pair: str,
|
||||
open_rate: float,
|
||||
amount: float, # quote currency, includes leverage
|
||||
stake_amount: float,
|
||||
leverage: float,
|
||||
is_short: bool
|
||||
) -> Optional[float]:
|
||||
|
||||
if self.trading_mode in TradingMode.SPOT:
|
||||
return None
|
||||
elif (
|
||||
self.trading_mode == TradingMode.FUTURES
|
||||
):
|
||||
isolated_liq = self.get_or_calculate_liquidation_price(
|
||||
pair=pair,
|
||||
open_rate=open_rate,
|
||||
is_short=is_short,
|
||||
amount=amount,
|
||||
stake_amount=stake_amount,
|
||||
wallet_balance=stake_amount, # In isolated mode, stake-amount = wallet size
|
||||
mm_ex_1=0.0,
|
||||
upnl_ex_1=0.0,
|
||||
)
|
||||
return isolated_liq
|
||||
else:
|
||||
raise OperationalException(
|
||||
"Freqtrade currently only supports futures for leverage trading.")
|
||||
|
||||
def funding_fee_cutoff(self, open_date: datetime):
|
||||
"""
|
||||
:param open_date: The open date for a trade
|
||||
@@ -2622,7 +2592,7 @@ class Exchange:
|
||||
else:
|
||||
return 0.0
|
||||
|
||||
def get_or_calculate_liquidation_price(
|
||||
def get_liquidation_price(
|
||||
self,
|
||||
pair: str,
|
||||
# Dry-run
|
||||
@@ -2630,7 +2600,7 @@ class Exchange:
|
||||
is_short: bool,
|
||||
amount: float, # Absolute value of position size
|
||||
stake_amount: float,
|
||||
wallet_balance: float, # Or margin balance
|
||||
wallet_balance: float = 0.0,
|
||||
mm_ex_1: float = 0.0, # (Binance) Cross only
|
||||
upnl_ex_1: float = 0.0, # (Binance) Cross only
|
||||
) -> Optional[float]:
|
||||
|
@@ -1732,12 +1732,12 @@ class FreqtradeBot(LoggingMixin):
|
||||
# TODO: Margin will need to use interest_rate as well.
|
||||
# interest_rate = self.exchange.get_interest_rate()
|
||||
trade.set_liquidation_price(self.exchange.get_liquidation_price(
|
||||
leverage=trade.leverage,
|
||||
pair=trade.pair,
|
||||
open_rate=trade.open_rate,
|
||||
is_short=trade.is_short,
|
||||
amount=trade.amount,
|
||||
stake_amount=trade.stake_amount,
|
||||
open_rate=trade.open_rate,
|
||||
is_short=trade.is_short
|
||||
wallet_balance=trade.stake_amount,
|
||||
))
|
||||
|
||||
# Updating wallets when order is closed
|
||||
|
@@ -881,7 +881,7 @@ class Backtesting:
|
||||
open_rate=propose_rate,
|
||||
amount=amount,
|
||||
stake_amount=trade.stake_amount,
|
||||
leverage=leverage,
|
||||
wallet_balance=trade.stake_amount,
|
||||
is_short=is_short,
|
||||
))
|
||||
|
||||
|
Reference in New Issue
Block a user