mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-19 21:40:24 +00:00
Clearer wallets variable/parameter wording
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}."
|
||||
|
||||
Reference in New Issue
Block a user