diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 3adb174b1..65f15b98b 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -691,8 +691,13 @@ class Exchange: pair: str, price: float, stoploss: float - ) -> Optional[float]: - return self._get_stake_amount_limit(pair, price, stoploss, 'max') + ) -> float: + 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( self, diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 44665ff61..073f4d3f3 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -546,9 +546,6 @@ class FreqtradeBot(LoggingMixin): max_stake_amount = self.exchange.get_max_pair_stake_amount(trade.pair, current_rate, 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() logger.debug(f"Calling adjust_trade_position for pair {trade.pair}") 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: 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, default_retval=stake_amount)( pair=pair, current_time=datetime.now(timezone.utc), diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index e973b1fbe..ecfc5c342 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -414,9 +414,6 @@ class Backtesting: 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) 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_amount = strategy_safe_wrapper(self.strategy.adjust_trade_position, 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 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() pos_adjust = trade is not None