Clearer wallets variable/parameter wording

This commit is contained in:
Matthias
2024-02-25 09:07:53 +01:00
parent aad327b1fe
commit e2d3774b07
2 changed files with 11 additions and 11 deletions

View File

@@ -201,7 +201,7 @@ class Backtesting:
self.prepare_backtest(False)
self.wallets = Wallets(self.config, self.exchange, log=False)
self.wallets = Wallets(self.config, self.exchange, is_backtest=True)
self.progress = BTProgress()
self.abort = False

View File

@@ -36,9 +36,9 @@ class PositionWallet(NamedTuple):
class Wallets:
def __init__(self, config: Config, exchange: Exchange, log: bool = True) -> None:
def __init__(self, config: Config, exchange: Exchange, is_backtest: bool = False) -> None:
self._config = config
self._log = log
self._is_backtest = is_backtest
self._exchange = exchange
self._wallets: Dict[str, Wallet] = {}
self._positions: Dict[str, PositionWallet] = {}
@@ -78,11 +78,11 @@ class Wallets:
_wallets = {}
_positions = {}
open_trades = Trade.get_trades_proxy(is_open=True)
# If not backtesting...
# TODO: potentially remove the ._log workaround to determine backtest mode.
if self._log:
if not self._is_backtest:
# Live / Dry-run mode
tot_profit = Trade.get_total_closed_profit()
else:
# Backtest mode
tot_profit = LocalTrade.total_profit
tot_profit += sum(trade.realized_profit for trade in open_trades)
tot_in_trades = sum(trade.stake_amount for trade in open_trades)
@@ -177,7 +177,7 @@ class Wallets:
self._update_live()
else:
self._update_dry()
if self._log:
if not self._is_backtest:
logger.info('Wallets synced.')
self._last_wallet_refresh = dt_now()
@@ -341,19 +341,19 @@ class Wallets:
max_allowed_stake = min(max_allowed_stake, max_stake_amount - trade_amount)
if min_stake_amount is not None and min_stake_amount > max_allowed_stake:
if self._log:
if not self._is_backtest:
logger.warning("Minimum stake amount > available balance. "
f"{min_stake_amount} > {max_allowed_stake}")
return 0
if min_stake_amount is not None and stake_amount < min_stake_amount:
if self._log:
if not self._is_backtest:
logger.info(
f"Stake amount for pair {pair} is too small "
f"({stake_amount} < {min_stake_amount}), adjusting to {min_stake_amount}."
)
if stake_amount * 1.3 < min_stake_amount:
# Top-cap stake-amount adjustments to +30%.
if self._log:
if not self._is_backtest:
logger.info(
f"Adjusted stake amount for pair {pair} is more than 30% bigger than "
f"the desired stake amount of ({stake_amount:.8f} * 1.3 = "
@@ -363,7 +363,7 @@ class Wallets:
stake_amount = min_stake_amount
if stake_amount > max_allowed_stake:
if self._log:
if not self._is_backtest:
logger.info(
f"Stake amount for pair {pair} is too big "
f"({stake_amount} > {max_allowed_stake}), adjusting to {max_allowed_stake}."