mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
refactor: rename dry-liquidation parameter
passing all open trades will be more flexible for the future.
This commit is contained in:
@@ -153,7 +153,7 @@ class Binance(Exchange):
|
||||
stake_amount: float,
|
||||
leverage: float,
|
||||
wallet_balance: float, # Or margin balance
|
||||
other_trades: list,
|
||||
open_trades: list,
|
||||
) -> Optional[float]:
|
||||
"""
|
||||
Important: Must be fetching data from cached values as this is used by backtesting!
|
||||
@@ -171,7 +171,7 @@ class Binance(Exchange):
|
||||
:param wallet_balance: Amount of margin_mode in the wallet being used to trade
|
||||
Cross-Margin Mode: crossWalletBalance
|
||||
Isolated-Margin Mode: isolatedWalletBalance
|
||||
:param other_trades: List of other open trades in the same wallet
|
||||
:param open_trades: List of open trades in the same wallet
|
||||
|
||||
# * Only required for Cross
|
||||
:param mm_ex_1: (TMM)
|
||||
@@ -191,7 +191,7 @@ class Binance(Exchange):
|
||||
if self.margin_mode == MarginMode.CROSS:
|
||||
mm_ex_1: float = 0.0
|
||||
upnl_ex_1: float = 0.0
|
||||
for trade in other_trades:
|
||||
for trade in open_trades:
|
||||
mm_ratio1, maint_amnt1 = self.get_maintenance_ratio_and_amt(
|
||||
trade["pair"], trade["stake_amount"]
|
||||
)
|
||||
|
||||
@@ -147,7 +147,7 @@ class Bybit(Exchange):
|
||||
stake_amount: float,
|
||||
leverage: float,
|
||||
wallet_balance: float, # Or margin balance
|
||||
other_trades: list,
|
||||
open_trades: list,
|
||||
) -> Optional[float]:
|
||||
"""
|
||||
Important: Must be fetching data from cached values as this is used by backtesting!
|
||||
@@ -177,7 +177,7 @@ class Bybit(Exchange):
|
||||
:param wallet_balance: Amount of margin_mode in the wallet being used to trade
|
||||
Cross-Margin Mode: crossWalletBalance
|
||||
Isolated-Margin Mode: isolatedWalletBalance
|
||||
:param other_trades: List of other open trades in the same wallet
|
||||
:param open_trades: List of other open trades in the same wallet
|
||||
"""
|
||||
|
||||
market = self.markets[pair]
|
||||
|
||||
@@ -3532,7 +3532,7 @@ class Exchange:
|
||||
stake_amount: float,
|
||||
leverage: float,
|
||||
wallet_balance: float,
|
||||
other_trades: Optional[list] = None,
|
||||
open_trades: Optional[list] = None,
|
||||
) -> Optional[float]:
|
||||
"""
|
||||
Set's the margin mode on the exchange to cross or isolated for a specific pair
|
||||
@@ -3554,7 +3554,7 @@ class Exchange:
|
||||
leverage=leverage,
|
||||
stake_amount=stake_amount,
|
||||
wallet_balance=wallet_balance,
|
||||
other_trades=other_trades or [],
|
||||
open_trades=open_trades or [],
|
||||
)
|
||||
else:
|
||||
positions = self.fetch_positions(pair)
|
||||
@@ -3580,7 +3580,7 @@ class Exchange:
|
||||
stake_amount: float,
|
||||
leverage: float,
|
||||
wallet_balance: float, # Or margin balance
|
||||
other_trades: list,
|
||||
open_trades: list,
|
||||
) -> Optional[float]:
|
||||
"""
|
||||
Important: Must be fetching data from cached values as this is used by backtesting!
|
||||
@@ -3605,7 +3605,7 @@ class Exchange:
|
||||
:param wallet_balance: Amount of margin_mode in the wallet being used to trade
|
||||
Cross-Margin Mode: crossWalletBalance
|
||||
Isolated-Margin Mode: isolatedWalletBalance
|
||||
:param other_trades: List of other open trades in the same wallet
|
||||
:param open_trades: List of other open trades in the same wallet
|
||||
"""
|
||||
|
||||
market = self.markets[pair]
|
||||
|
||||
@@ -43,7 +43,7 @@ def update_liquidation_prices(
|
||||
stake_amount=t.stake_amount,
|
||||
leverage=trade.leverage,
|
||||
wallet_balance=total_wallet_stake,
|
||||
other_trades=[tr for tr in open_trades if t.id != tr.id],
|
||||
open_trades=[tr for tr in open_trades],
|
||||
)
|
||||
)
|
||||
elif trade:
|
||||
|
||||
@@ -6009,7 +6009,7 @@ def test_get_liquidation_price1(mocker, default_conf):
|
||||
stake_amount=18.884 * 0.8,
|
||||
leverage=leverage,
|
||||
wallet_balance=18.884 * 0.8,
|
||||
other_trades=[],
|
||||
open_trades=[],
|
||||
)
|
||||
|
||||
|
||||
@@ -6140,7 +6140,7 @@ def test_get_liquidation_price(
|
||||
wallet_balance=amount * open_rate / leverage,
|
||||
leverage=leverage,
|
||||
is_short=is_short,
|
||||
other_trades=[],
|
||||
open_trades=[],
|
||||
)
|
||||
if expected_liq is None:
|
||||
assert liq is None
|
||||
|
||||
Reference in New Issue
Block a user