moved max_stake_amount check for None to exchange.get_max_pair_stake_amount

This commit is contained in:
Sam Germain 2022-02-03 00:10:14 -06:00
parent 6b6b35ac1c
commit 8c680d75b9
3 changed files with 7 additions and 14 deletions

View File

@ -691,8 +691,13 @@ class Exchange:
pair: str, pair: str,
price: float, price: float,
stoploss: float stoploss: float
) -> Optional[float]: ) -> float:
return self._get_stake_amount_limit(pair, price, stoploss, 'max') max_stake_amount = self._get_stake_amount_limit(pair, price, stoploss, 'max')
if max_stake_amount is None:
# * Should never be executed
raise OperationalException(f'{self.name}.get_max_pair_stake_amount should'
'never set max_stake_amount to None')
return max_stake_amount
def _get_stake_amount_limit( def _get_stake_amount_limit(
self, self,

View File

@ -546,9 +546,6 @@ class FreqtradeBot(LoggingMixin):
max_stake_amount = self.exchange.get_max_pair_stake_amount(trade.pair, max_stake_amount = self.exchange.get_max_pair_stake_amount(trade.pair,
current_rate, current_rate,
self.strategy.stoploss) self.strategy.stoploss)
if max_stake_amount is None:
# * Should never be executed
raise OperationalException(f'max_stake_amount is None for {trade}')
stake_available = self.wallets.get_available_stake_amount() stake_available = self.wallets.get_available_stake_amount()
logger.debug(f"Calling adjust_trade_position for pair {trade.pair}") logger.debug(f"Calling adjust_trade_position for pair {trade.pair}")
stake_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position, stake_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position,
@ -858,9 +855,6 @@ class FreqtradeBot(LoggingMixin):
if not self.edge and trade is None: if not self.edge and trade is None:
stake_available = self.wallets.get_available_stake_amount() stake_available = self.wallets.get_available_stake_amount()
if max_stake_amount is None:
# * Should never be executed
raise OperationalException(f'max_stake_amount is None for {trade}')
stake_amount = strategy_safe_wrapper(self.strategy.custom_stake_amount, stake_amount = strategy_safe_wrapper(self.strategy.custom_stake_amount,
default_retval=stake_amount)( default_retval=stake_amount)(
pair=pair, current_time=datetime.now(timezone.utc), pair=pair, current_time=datetime.now(timezone.utc),

View File

@ -414,9 +414,6 @@ class Backtesting:
current_profit = trade.calc_profit_ratio(row[OPEN_IDX]) current_profit = trade.calc_profit_ratio(row[OPEN_IDX])
min_stake = self.exchange.get_min_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1) min_stake = self.exchange.get_min_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1)
max_stake = self.exchange.get_max_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1) max_stake = self.exchange.get_max_pair_stake_amount(trade.pair, row[OPEN_IDX], -0.1)
if max_stake is None:
# * Should never be executed
raise OperationalException(f'max_stake_amount is None for {trade}')
stake_available = self.wallets.get_available_stake_amount() stake_available = self.wallets.get_available_stake_amount()
stake_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position, stake_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position,
default_retval=None)( default_retval=None)(
@ -557,9 +554,6 @@ class Backtesting:
min_stake_amount = self.exchange.get_min_pair_stake_amount(pair, propose_rate, -0.05) or 0 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) or 0
if max_stake_amount is None:
# * Should never be executed
raise OperationalException(f'max_stake_amount is None for {trade}')
stake_available = self.wallets.get_available_stake_amount() stake_available = self.wallets.get_available_stake_amount()
pos_adjust = trade is not None pos_adjust = trade is not None