Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_helpers/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@
"type": "string"
}
},
"x": {
"verbosity": {
"description": "Logging verbosity level.",
"type": "string",
"enum": [
Expand Down
2 changes: 1 addition & 1 deletion freqtrade/configuration/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
"type": "array",
"items": {"type": "string"},
},
"x": {
"verbosity": {
"description": "Logging verbosity level.",
"type": "string",
"enum": ["error", "info"],
Expand Down
61 changes: 36 additions & 25 deletions freqtrade/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import logging
from datetime import datetime, timedelta
from typing import NamedTuple
from typing import Literal, NamedTuple

from freqtrade.constants import UNLIMITED_STAKE_AMOUNT, Config, IntOrInf
from freqtrade.enums import RunMode, TradingMode
Expand Down Expand Up @@ -227,8 +227,7 @@ def update(self, require_update: bool = True) -> None:
self._update_live()
else:
self._update_dry()
if not self._is_backtest:
logger.info("Wallets synced.")
self._local_log("Wallets synced.")
self._last_wallet_refresh = dt_now()

def get_all_balances(self) -> dict[str, Wallet]:
Expand Down Expand Up @@ -392,7 +391,10 @@ def validate_stake_amount(
trade_amount: float | None,
):
if not stake_amount:
logger.debug(f"Stake amount is {stake_amount}, ignoring possible trade for {pair}.")
self._local_log(
f"Stake amount is {stake_amount}, ignoring possible trade for {pair}.",
level="debug",
)
return 0

max_allowed_stake = min(max_stake_amount, self.get_available_stake_amount())
Expand All @@ -402,34 +404,43 @@ def validate_stake_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 not self._is_backtest:
logger.warning(
"Minimum stake amount > available balance. "
f"{min_stake_amount} > {max_allowed_stake}"
)
self._local_log(
"Minimum stake amount > available balance. "
f"{min_stake_amount} > {max_allowed_stake}",
level="warning",
)
return 0
if min_stake_amount is not None and stake_amount < min_stake_amount:
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}."
)
self._local_log(
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 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 = "
f"{stake_amount * 1.3:.8f}) < {min_stake_amount}), ignoring trade."
)
self._local_log(
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"{stake_amount * 1.3:.8f}) < {min_stake_amount}), ignoring trade."
)
return 0
stake_amount = min_stake_amount

if stake_amount > max_allowed_stake:
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}."
)
self._local_log(
f"Stake amount for pair {pair} is too big "
f"({stake_amount} > {max_allowed_stake}), adjusting to {max_allowed_stake}."
)
stake_amount = max_allowed_stake
return stake_amount

def _local_log(self, msg: str, level: Literal["info", "warning", "debug"] = "info") -> None:
"""
Log a message to the local log.
"""
if not self._is_backtest:
if level == "warning":
logger.warning(msg)
elif level == "debug":
logger.debug(msg)
else:
logger.info(msg)
Loading