wallets.validate_stake_amount added param max_stake_available
This commit is contained in:
@@ -866,8 +866,12 @@ class FreqtradeBot(LoggingMixin):
|
||||
entry_tag=entry_tag, side=trade_side
|
||||
)
|
||||
|
||||
stake_amount = min(stake_amount, max_stake_amount)
|
||||
stake_amount = self.wallets.validate_stake_amount(pair, stake_amount, min_stake_amount)
|
||||
stake_amount = self.wallets.validate_stake_amount(
|
||||
pair=pair,
|
||||
stake_amount=stake_amount,
|
||||
min_stake_amount=min_stake_amount,
|
||||
max_stake_amount=max_stake_amount,
|
||||
)
|
||||
|
||||
return enter_limit_requested, stake_amount
|
||||
|
||||
|
@@ -553,7 +553,7 @@ class Backtesting:
|
||||
propose_rate = min(max(propose_rate, row[LOW_IDX]), row[HIGH_IDX])
|
||||
|
||||
min_stake_amount = self.exchange.get_min_pair_stake_amount(pair, propose_rate, -0.05) or 0
|
||||
max_stake_amount = self.exchange.get_max_pair_stake_amount(pair, propose_rate, -0.05) or 0
|
||||
max_stake_amount = self.exchange.get_max_pair_stake_amount(pair, propose_rate, -0.05)
|
||||
stake_available = self.wallets.get_available_stake_amount()
|
||||
|
||||
pos_adjust = trade is not None
|
||||
@@ -570,7 +570,12 @@ class Backtesting:
|
||||
max_stake=min(stake_available, max_stake_amount),
|
||||
entry_tag=entry_tag, side=direction)
|
||||
|
||||
stake_amount = self.wallets.validate_stake_amount(pair, stake_amount, min_stake_amount)
|
||||
stake_amount = self.wallets.validate_stake_amount(
|
||||
pair=pair,
|
||||
stake_amount=stake_amount,
|
||||
min_stake_amount=min_stake_amount,
|
||||
max_stake_amount=max_stake_amount,
|
||||
)
|
||||
|
||||
if not stake_amount:
|
||||
# In case of pos adjust, still return the original trade
|
||||
|
@@ -238,12 +238,12 @@ class Wallets:
|
||||
|
||||
return self._check_available_stake_amount(stake_amount, available_amount)
|
||||
|
||||
def validate_stake_amount(self, pair, stake_amount, min_stake_amount):
|
||||
def validate_stake_amount(self, pair, stake_amount, min_stake_amount, max_stake_amount):
|
||||
if not stake_amount:
|
||||
logger.debug(f"Stake amount is {stake_amount}, ignoring possible trade for {pair}.")
|
||||
return 0
|
||||
|
||||
max_stake_amount = self.get_available_stake_amount()
|
||||
max_stake_amount = min(max_stake_amount, self.get_available_stake_amount())
|
||||
|
||||
if min_stake_amount > max_stake_amount:
|
||||
if self._log:
|
||||
|
Reference in New Issue
Block a user