mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: add cross margin balance logic
This commit is contained in:
@@ -136,12 +136,22 @@ class Wallets:
|
||||
|
||||
used_stake = tot_in_trades
|
||||
|
||||
cross_margin = 0.0
|
||||
if self._config.get("margin_mode") == "cross":
|
||||
# In cross-margin mode, the total balance is used as collateral.
|
||||
for curr, bal in self._start_cap.items():
|
||||
if curr == self._stake_currency:
|
||||
continue
|
||||
rate = self._exchange.get_conversion_rate(curr, self._stake_currency)
|
||||
if rate:
|
||||
cross_margin += bal * rate
|
||||
|
||||
current_stake = self._start_cap.get(self._stake_currency, 0) + tot_profit - tot_in_trades
|
||||
total_stake = current_stake + used_stake
|
||||
|
||||
_wallets[self._stake_currency] = Wallet(
|
||||
currency=self._stake_currency,
|
||||
free=current_stake,
|
||||
free=current_stake + cross_margin,
|
||||
used=used_stake,
|
||||
total=total_stake,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user