Fallback to "initialMargin" if collateral is not set

This commit is contained in:
Matthias 2023-04-24 12:13:24 +02:00
parent e99af87b6d
commit 829724c0ec

View File

@ -11,6 +11,7 @@ from freqtrade.constants import UNLIMITED_STAKE_AMOUNT, Config
from freqtrade.enums import RunMode, TradingMode from freqtrade.enums import RunMode, TradingMode
from freqtrade.exceptions import DependencyException from freqtrade.exceptions import DependencyException
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.misc import safe_value_fallback
from freqtrade.persistence import LocalTrade, Trade from freqtrade.persistence import LocalTrade, Trade
@ -148,7 +149,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 = position['collateral'] or 0.0 collateral = safe_value_fallback(position, 'collateral', 'initialMargin', 0.0)
leverage = position['leverage'] leverage = position['leverage']
self._positions[symbol] = PositionWallet( self._positions[symbol] = PositionWallet(
symbol, position=size, symbol, position=size,