fix: use initialMargin over collateral for position wallet

closes #11415
This commit is contained in:
Matthias
2025-03-02 14:17:12 +01:00
parent cc0337585e
commit 13e9f8a98e
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -197,7 +197,7 @@ class Wallets:
# Position is not open ... # Position is not open ...
continue continue
size = self._exchange._contracts_to_amount(symbol, position["contracts"]) size = self._exchange._contracts_to_amount(symbol, position["contracts"])
collateral = safe_value_fallback(position, "collateral", "initialMargin", 0.0) collateral = safe_value_fallback(position, "initialMargin", "collateral", 0.0)
leverage = position.get("leverage") leverage = position.get("leverage")
_parsed_positions[symbol] = PositionWallet( _parsed_positions[symbol] = PositionWallet(
symbol, symbol,
+4 -3
View File
@@ -577,7 +577,7 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers, proxy_coin, marg
"symbol": "ETH/USDT:USDT", "symbol": "ETH/USDT:USDT",
"timestamp": None, "timestamp": None,
"datetime": None, "datetime": None,
"initialMargin": 0.0, "initialMargin": 20,
"initialMarginPercentage": None, "initialMarginPercentage": None,
"maintenanceMargin": 0.0, "maintenanceMargin": 0.0,
"maintenanceMarginPercentage": 0.005, "maintenanceMarginPercentage": 0.005,
@@ -590,8 +590,9 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers, proxy_coin, marg
"marginRatio": None, "marginRatio": None,
"liquidationPrice": 0.0, "liquidationPrice": 0.0,
"markPrice": 2896.41, "markPrice": 2896.41,
"collateral": 20, # Collateral is in USDT - and can be higher than position size in cross mode
"marginType": "isolated", "collateral": 50,
"marginType": "cross",
"side": "short", "side": "short",
"percentage": None, "percentage": None,
} }