mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
Clearer wallets variable/parameter wording
This commit is contained in:
@@ -201,7 +201,7 @@ class Backtesting:
|
|||||||
|
|
||||||
self.prepare_backtest(False)
|
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.progress = BTProgress()
|
||||||
self.abort = False
|
self.abort = False
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ class PositionWallet(NamedTuple):
|
|||||||
|
|
||||||
class Wallets:
|
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._config = config
|
||||||
self._log = log
|
self._is_backtest = is_backtest
|
||||||
self._exchange = exchange
|
self._exchange = exchange
|
||||||
self._wallets: Dict[str, Wallet] = {}
|
self._wallets: Dict[str, Wallet] = {}
|
||||||
self._positions: Dict[str, PositionWallet] = {}
|
self._positions: Dict[str, PositionWallet] = {}
|
||||||
@@ -78,11 +78,11 @@ class Wallets:
|
|||||||
_wallets = {}
|
_wallets = {}
|
||||||
_positions = {}
|
_positions = {}
|
||||||
open_trades = Trade.get_trades_proxy(is_open=True)
|
open_trades = Trade.get_trades_proxy(is_open=True)
|
||||||
# If not backtesting...
|
if not self._is_backtest:
|
||||||
# TODO: potentially remove the ._log workaround to determine backtest mode.
|
# Live / Dry-run mode
|
||||||
if self._log:
|
|
||||||
tot_profit = Trade.get_total_closed_profit()
|
tot_profit = Trade.get_total_closed_profit()
|
||||||
else:
|
else:
|
||||||
|
# Backtest mode
|
||||||
tot_profit = LocalTrade.total_profit
|
tot_profit = LocalTrade.total_profit
|
||||||
tot_profit += sum(trade.realized_profit for trade in open_trades)
|
tot_profit += sum(trade.realized_profit for trade in open_trades)
|
||||||
tot_in_trades = sum(trade.stake_amount 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()
|
self._update_live()
|
||||||
else:
|
else:
|
||||||
self._update_dry()
|
self._update_dry()
|
||||||
if self._log:
|
if not self._is_backtest:
|
||||||
logger.info('Wallets synced.')
|
logger.info('Wallets synced.')
|
||||||
self._last_wallet_refresh = dt_now()
|
self._last_wallet_refresh = dt_now()
|
||||||
|
|
||||||
@@ -341,19 +341,19 @@ class Wallets:
|
|||||||
max_allowed_stake = min(max_allowed_stake, max_stake_amount - trade_amount)
|
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 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. "
|
logger.warning("Minimum stake amount > available balance. "
|
||||||
f"{min_stake_amount} > {max_allowed_stake}")
|
f"{min_stake_amount} > {max_allowed_stake}")
|
||||||
return 0
|
return 0
|
||||||
if min_stake_amount is not None and stake_amount < min_stake_amount:
|
if min_stake_amount is not None and stake_amount < min_stake_amount:
|
||||||
if self._log:
|
if not self._is_backtest:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Stake amount for pair {pair} is too small "
|
f"Stake amount for pair {pair} is too small "
|
||||||
f"({stake_amount} < {min_stake_amount}), adjusting to {min_stake_amount}."
|
f"({stake_amount} < {min_stake_amount}), adjusting to {min_stake_amount}."
|
||||||
)
|
)
|
||||||
if stake_amount * 1.3 < min_stake_amount:
|
if stake_amount * 1.3 < min_stake_amount:
|
||||||
# Top-cap stake-amount adjustments to +30%.
|
# Top-cap stake-amount adjustments to +30%.
|
||||||
if self._log:
|
if not self._is_backtest:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Adjusted stake amount for pair {pair} is more than 30% bigger than "
|
f"Adjusted stake amount for pair {pair} is more than 30% bigger than "
|
||||||
f"the desired stake amount of ({stake_amount:.8f} * 1.3 = "
|
f"the desired stake amount of ({stake_amount:.8f} * 1.3 = "
|
||||||
@@ -363,7 +363,7 @@ class Wallets:
|
|||||||
stake_amount = min_stake_amount
|
stake_amount = min_stake_amount
|
||||||
|
|
||||||
if stake_amount > max_allowed_stake:
|
if stake_amount > max_allowed_stake:
|
||||||
if self._log:
|
if not self._is_backtest:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Stake amount for pair {pair} is too big "
|
f"Stake amount for pair {pair} is too big "
|
||||||
f"({stake_amount} > {max_allowed_stake}), adjusting to {max_allowed_stake}."
|
f"({stake_amount} > {max_allowed_stake}), adjusting to {max_allowed_stake}."
|
||||||
|
|||||||
Reference in New Issue
Block a user