refactor: rename dry-liquidation parameter

passing all open trades will be more flexible for the future.
This commit is contained in:
Matthias
2024-08-31 08:20:14 +02:00
parent 45e75f3d09
commit 1473abf19a
5 changed files with 12 additions and 12 deletions

View File

@@ -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"]
)

View File

@@ -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]

View File

@@ -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]

View File

@@ -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:

View File

@@ -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