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

View File

@@ -197,7 +197,7 @@ class Wallets:
# Position is not open ...
continue
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")
_parsed_positions[symbol] = PositionWallet(
symbol,

View File

@@ -577,7 +577,7 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers, proxy_coin, marg
"symbol": "ETH/USDT:USDT",
"timestamp": None,
"datetime": None,
"initialMargin": 0.0,
"initialMargin": 20,
"initialMarginPercentage": None,
"maintenanceMargin": 0.0,
"maintenanceMarginPercentage": 0.005,
@@ -590,8 +590,9 @@ def test_rpc_balance_handle(default_conf_usdt, mocker, tickers, proxy_coin, marg
"marginRatio": None,
"liquidationPrice": 0.0,
"markPrice": 2896.41,
"collateral": 20,
"marginType": "isolated",
# Collateral is in USDT - and can be higher than position size in cross mode
"collateral": 50,
"marginType": "cross",
"side": "short",
"percentage": None,
}